{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "253ab18f-d2dc-4dee-a9db-5255571056d6",
   "metadata": {},
   "outputs": [],
   "source": [
    "### Evaluate colocalization results\n",
    "### Load the results saved in R2 script and check out some summaries"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "802f0d1c-925e-480b-a547-865cc6d997b2",
   "metadata": {
    "tags": []
   },
   "source": [
    "# Libraries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "d187711e-139c-4eaf-bcaf-5795174c795d",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "Attaching package: ‘dplyr’\n",
      "\n",
      "\n",
      "The following objects are masked from ‘package:stats’:\n",
      "\n",
      "    filter, lag\n",
      "\n",
      "\n",
      "The following objects are masked from ‘package:base’:\n",
      "\n",
      "    intersect, setdiff, setequal, union\n",
      "\n",
      "\n",
      "\n",
      "Attaching package: ‘data.table’\n",
      "\n",
      "\n",
      "The following objects are masked from ‘package:dplyr’:\n",
      "\n",
      "    between, first, last\n",
      "\n",
      "\n",
      "── \u001b[1mAttaching packages\u001b[22m ─────────────────────────────────────── tidyverse 1.3.1 ──\n",
      "\n",
      "\u001b[32m✔\u001b[39m \u001b[34mggplot2\u001b[39m 3.3.6     \u001b[32m✔\u001b[39m \u001b[34mreadr  \u001b[39m 2.1.2\n",
      "\u001b[32m✔\u001b[39m \u001b[34mtibble \u001b[39m 3.1.7     \u001b[32m✔\u001b[39m \u001b[34mpurrr  \u001b[39m 0.3.4\n",
      "\u001b[32m✔\u001b[39m \u001b[34mtidyr  \u001b[39m 1.2.0     \u001b[32m✔\u001b[39m \u001b[34mforcats\u001b[39m 0.5.1\n",
      "\n",
      "── \u001b[1mConflicts\u001b[22m ────────────────────────────────────────── tidyverse_conflicts() ──\n",
      "\u001b[31m✖\u001b[39m \u001b[34mdata.table\u001b[39m::\u001b[32mbetween()\u001b[39m masks \u001b[34mdplyr\u001b[39m::between()\n",
      "\u001b[31m✖\u001b[39m \u001b[34mdplyr\u001b[39m::\u001b[32mfilter()\u001b[39m       masks \u001b[34mstats\u001b[39m::filter()\n",
      "\u001b[31m✖\u001b[39m \u001b[34mdata.table\u001b[39m::\u001b[32mfirst()\u001b[39m   masks \u001b[34mdplyr\u001b[39m::first()\n",
      "\u001b[31m✖\u001b[39m \u001b[34mdplyr\u001b[39m::\u001b[32mlag()\u001b[39m          masks \u001b[34mstats\u001b[39m::lag()\n",
      "\u001b[31m✖\u001b[39m \u001b[34mdata.table\u001b[39m::\u001b[32mlast()\u001b[39m    masks \u001b[34mdplyr\u001b[39m::last()\n",
      "\u001b[31m✖\u001b[39m \u001b[34mpurrr\u001b[39m::\u001b[32mtranspose()\u001b[39m    masks \u001b[34mdata.table\u001b[39m::transpose()\n",
      "\n",
      "\n",
      "Attaching package: ‘reshape2’\n",
      "\n",
      "\n",
      "The following object is masked from ‘package:tidyr’:\n",
      "\n",
      "    smiths\n",
      "\n",
      "\n",
      "The following objects are masked from ‘package:data.table’:\n",
      "\n",
      "    dcast, melt\n",
      "\n",
      "\n",
      "Loading required package: lattice\n",
      "\n",
      "\n",
      "Attaching package: ‘caret’\n",
      "\n",
      "\n",
      "The following object is masked from ‘package:purrr’:\n",
      "\n",
      "    lift\n",
      "\n",
      "\n",
      "This is a new update to coloc.\n",
      "\n",
      "\n",
      "Attaching package: ‘coloc’\n",
      "\n",
      "\n",
      "The following object is masked from ‘package:caret’:\n",
      "\n",
      "    sensitivity\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "source('MS1_Libraries.r')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e59e15e0-23cd-457b-b704-05dbfe404876",
   "metadata": {},
   "source": [
    "# Parameters"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "535e2290-2e3b-4cca-880f-8ce2d00f55b7",
   "metadata": {},
   "outputs": [],
   "source": [
    "path<-\"\"\n",
    "outdir<-\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "bfac0756-8f6a-4388-93a1-3e76a178b56e",
   "metadata": {},
   "outputs": [],
   "source": [
    "cell_type_var = c(\"CD4T\",\"CD8T\",\"monocyte\",\"NK\",\"B\",\"DC\")\n",
    "# c(\"CD4T\",\"CD8T\",\"monocyte\",\"NK\",\"B\",\"DC\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "96ec5300-7663-481d-b632-a0d23a9f5093",
   "metadata": {},
   "source": [
    "# Data "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9333eff6-72ae-4d8f-85a0-6030d4a6320c",
   "metadata": {
    "tags": []
   },
   "source": [
    "## Summaries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "9cbb9461-52d2-43e6-8027-9f2afb401615",
   "metadata": {},
   "outputs": [],
   "source": [
    "### EQTL coloclaization summaries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "8bb77e4e-8642-4bdc-a5d0-0c194374034b",
   "metadata": {},
   "outputs": [],
   "source": [
    "eqtl_summary = read.table(paste0(path, '/colocalization_results/EQTL_summary_update.csv'), row.names = NULL, sep = \",\", header = TRUE)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "40f8a037-6668-41f4-b681-605a7a89e211",
   "metadata": {},
   "outputs": [],
   "source": [
    "eqtl_summary$X = NULL"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "060ad489-167f-46a5-b56d-15d87c406773",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "1260"
      ],
      "text/latex": [
       "1260"
      ],
      "text/markdown": [
       "1260"
      ],
      "text/plain": [
       "[1] 1260"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "nrow(eqtl_summary)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "204331e6-b4ee-4b70-adc6-7c3d617bf01f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 2 × 4</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>parameter</th><th scope=col>value</th><th scope=col>trait</th><th scope=col>identifier</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>1</th><td>nsnps    </td><td>2.46200e+03</td><td>White blood cell count</td><td>DC1MB_TMEM176A</td></tr>\n",
       "\t<tr><th scope=row>2</th><td>PP.H0.abf</td><td>8.18261e-04</td><td>White blood cell count</td><td>DC1MB_TMEM176A</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 2 × 4\n",
       "\\begin{tabular}{r|llll}\n",
       "  & parameter & value & trait & identifier\\\\\n",
       "  & <chr> & <dbl> & <chr> & <chr>\\\\\n",
       "\\hline\n",
       "\t1 & nsnps     & 2.46200e+03 & White blood cell count & DC1MB\\_TMEM176A\\\\\n",
       "\t2 & PP.H0.abf & 8.18261e-04 & White blood cell count & DC1MB\\_TMEM176A\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 2 × 4\n",
       "\n",
       "| <!--/--> | parameter &lt;chr&gt; | value &lt;dbl&gt; | trait &lt;chr&gt; | identifier &lt;chr&gt; |\n",
       "|---|---|---|---|---|\n",
       "| 1 | nsnps     | 2.46200e+03 | White blood cell count | DC1MB_TMEM176A |\n",
       "| 2 | PP.H0.abf | 8.18261e-04 | White blood cell count | DC1MB_TMEM176A |\n",
       "\n"
      ],
      "text/plain": [
       "  parameter value       trait                  identifier    \n",
       "1 nsnps     2.46200e+03 White blood cell count DC1MB_TMEM176A\n",
       "2 PP.H0.abf 8.18261e-04 White blood cell count DC1MB_TMEM176A"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "head(eqtl_summary,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "c2a206a2-6df9-4748-a5e8-9faf15dce2fa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>\n",
       ".list-inline {list-style: none; margin:0; padding: 0}\n",
       ".list-inline>li {display: inline-block}\n",
       ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
       "</style>\n",
       "<ol class=list-inline><li>'White blood cell count'</li><li>'Crohn\\'s Disease'</li><li>'Inflammatory Bowel Disease'</li><li>'Multiple Sclerosis'</li><li>'Rheumatoid Arthritis'</li><li>'Asthma'</li><li>'Type_1_Diabetes'</li></ol>\n"
      ],
      "text/latex": [
       "\\begin{enumerate*}\n",
       "\\item 'White blood cell count'\n",
       "\\item 'Crohn\\textbackslash{}'s Disease'\n",
       "\\item 'Inflammatory Bowel Disease'\n",
       "\\item 'Multiple Sclerosis'\n",
       "\\item 'Rheumatoid Arthritis'\n",
       "\\item 'Asthma'\n",
       "\\item 'Type\\_1\\_Diabetes'\n",
       "\\end{enumerate*}\n"
      ],
      "text/markdown": [
       "1. 'White blood cell count'\n",
       "2. 'Crohn\\'s Disease'\n",
       "3. 'Inflammatory Bowel Disease'\n",
       "4. 'Multiple Sclerosis'\n",
       "5. 'Rheumatoid Arthritis'\n",
       "6. 'Asthma'\n",
       "7. 'Type_1_Diabetes'\n",
       "\n",
       "\n"
      ],
      "text/plain": [
       "[1] \"White blood cell count\"     \"Crohn's Disease\"           \n",
       "[3] \"Inflammatory Bowel Disease\" \"Multiple Sclerosis\"        \n",
       "[5] \"Rheumatoid Arthritis\"       \"Asthma\"                    \n",
       "[7] \"Type_1_Diabetes\"           "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "unique(eqtl_summary$trait)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "ac50d287-9b5d-4556-ada8-6048d1d16386",
   "metadata": {},
   "outputs": [],
   "source": [
    "eqtl_summary = unique(eqtl_summary)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "0c57ec7e-f676-4fce-b0d4-65c2dffb2960",
   "metadata": {},
   "outputs": [],
   "source": [
    "duplicates = eqtl_summary %>% group_by(parameter, trait, identifier) %>% count() %>% filter(n>= 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "83f668f5-507d-4ea9-9423-ceca78858a10",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [],
      "text/latex": [],
      "text/markdown": [],
      "text/plain": [
       "character(0)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "unique(duplicates$trait)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "909e941b-5c5c-4d46-88ed-66327f54c6e3",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Co-EQTL colocalization summaries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "74c85e40-2a30-4306-ad8e-778bd62b3a52",
   "metadata": {},
   "outputs": [],
   "source": [
    "coeqtl_summary = read.table(paste0(path, '/colocalization_results/COEQTL_summary_update.csv'), row.names = NULL, sep = \",\", header = TRUE)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "2e60f497-0d9c-4ccf-b00e-be12c19c998e",
   "metadata": {},
   "outputs": [],
   "source": [
    "coeqtl_summary$X = NULL"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "62aede66-8929-4efd-b76e-5145490f3fde",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "44688"
      ],
      "text/latex": [
       "44688"
      ],
      "text/markdown": [
       "44688"
      ],
      "text/plain": [
       "[1] 44688"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "nrow(coeqtl_summary)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "414849c2-215a-414f-af15-a5dbc9b32016",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 2 × 4</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>parameter</th><th scope=col>value</th><th scope=col>trait</th><th scope=col>identifier</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>1</th><td>nsnps    </td><td>2.461000e+03</td><td>White blood cell count</td><td>monocyte_TMEM176A___CAPG__TMEM176A</td></tr>\n",
       "\t<tr><th scope=row>2</th><td>PP.H0.abf</td><td>2.606173e-02</td><td>White blood cell count</td><td>monocyte_TMEM176A___CAPG__TMEM176A</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 2 × 4\n",
       "\\begin{tabular}{r|llll}\n",
       "  & parameter & value & trait & identifier\\\\\n",
       "  & <chr> & <dbl> & <chr> & <chr>\\\\\n",
       "\\hline\n",
       "\t1 & nsnps     & 2.461000e+03 & White blood cell count & monocyte\\_TMEM176A\\_\\_\\_CAPG\\_\\_TMEM176A\\\\\n",
       "\t2 & PP.H0.abf & 2.606173e-02 & White blood cell count & monocyte\\_TMEM176A\\_\\_\\_CAPG\\_\\_TMEM176A\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 2 × 4\n",
       "\n",
       "| <!--/--> | parameter &lt;chr&gt; | value &lt;dbl&gt; | trait &lt;chr&gt; | identifier &lt;chr&gt; |\n",
       "|---|---|---|---|---|\n",
       "| 1 | nsnps     | 2.461000e+03 | White blood cell count | monocyte_TMEM176A___CAPG__TMEM176A |\n",
       "| 2 | PP.H0.abf | 2.606173e-02 | White blood cell count | monocyte_TMEM176A___CAPG__TMEM176A |\n",
       "\n"
      ],
      "text/plain": [
       "  parameter value        trait                 \n",
       "1 nsnps     2.461000e+03 White blood cell count\n",
       "2 PP.H0.abf 2.606173e-02 White blood cell count\n",
       "  identifier                        \n",
       "1 monocyte_TMEM176A___CAPG__TMEM176A\n",
       "2 monocyte_TMEM176A___CAPG__TMEM176A"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "head(coeqtl_summary,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "bbe38511-c264-4bc6-a756-9752bcadf19d",
   "metadata": {},
   "outputs": [],
   "source": [
    "coeqtl_summary = unique(coeqtl_summary)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "a9c7f658-f3d3-4f73-81d8-0bc498bf0b4b",
   "metadata": {},
   "outputs": [],
   "source": [
    "duplicates = coeqtl_summary %>% group_by(parameter, trait, identifier) %>% count() %>% filter(n>= 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "289a0d48-77c4-4db7-ac5c-32d61bd7f4d6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [],
      "text/latex": [],
      "text/markdown": [],
      "text/plain": [
       "character(0)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "unique(duplicates$trait)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "8925b1ae-e0fe-4c96-8c61-d4003d06a2fb",
   "metadata": {},
   "outputs": [],
   "source": [
    "#unique(duplicates$parameter)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "f2ade7f4-16e7-4018-9b14-f1f4c85c6b0f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A grouped_df: 0 × 4</caption>\n",
       "<thead>\n",
       "\t<tr><th scope=col>parameter</th><th scope=col>trait</th><th scope=col>identifier</th><th scope=col>n</th></tr>\n",
       "\t<tr><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;int&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A grouped\\_df: 0 × 4\n",
       "\\begin{tabular}{llll}\n",
       " parameter & trait & identifier & n\\\\\n",
       " <chr> & <chr> & <chr> & <int>\\\\\n",
       "\\hline\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A grouped_df: 0 × 4\n",
       "\n",
       "| parameter &lt;chr&gt; | trait &lt;chr&gt; | identifier &lt;chr&gt; | n &lt;int&gt; |\n",
       "|---|---|---|---|\n",
       "\n"
      ],
      "text/plain": [
       "     parameter trait identifier n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "head(duplicates,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "e035efd4-9848-4a64-919f-7a48b79bcafd",
   "metadata": {},
   "outputs": [],
   "source": [
    "### Extract egene"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "dc53ab43-4ab9-4f52-8c35-458e10b23406",
   "metadata": {},
   "outputs": [],
   "source": [
    "coeqtl_summary$egene = str_extract(coeqtl_summary$identifier, '.*___')\n",
    "coeqtl_summary$egene = str_replace(coeqtl_summary$egene, '___', '')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b5e259ac-c2b6-4888-ae21-a4e6b4dabec0",
   "metadata": {
    "tags": []
   },
   "source": [
    "# Evaluate summaries"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a3c11cc1-129a-4313-a4b9-5e57278343d9",
   "metadata": {
    "tags": []
   },
   "source": [
    "## For EQTLs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "f357d86b-10c4-403b-a79d-907ea09f4947",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 2 × 4</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>parameter</th><th scope=col>value</th><th scope=col>trait</th><th scope=col>identifier</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>1</th><td>nsnps    </td><td>2.46200e+03</td><td>White blood cell count</td><td>DC1MB_TMEM176A</td></tr>\n",
       "\t<tr><th scope=row>2</th><td>PP.H0.abf</td><td>8.18261e-04</td><td>White blood cell count</td><td>DC1MB_TMEM176A</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 2 × 4\n",
       "\\begin{tabular}{r|llll}\n",
       "  & parameter & value & trait & identifier\\\\\n",
       "  & <chr> & <dbl> & <chr> & <chr>\\\\\n",
       "\\hline\n",
       "\t1 & nsnps     & 2.46200e+03 & White blood cell count & DC1MB\\_TMEM176A\\\\\n",
       "\t2 & PP.H0.abf & 8.18261e-04 & White blood cell count & DC1MB\\_TMEM176A\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 2 × 4\n",
       "\n",
       "| <!--/--> | parameter &lt;chr&gt; | value &lt;dbl&gt; | trait &lt;chr&gt; | identifier &lt;chr&gt; |\n",
       "|---|---|---|---|---|\n",
       "| 1 | nsnps     | 2.46200e+03 | White blood cell count | DC1MB_TMEM176A |\n",
       "| 2 | PP.H0.abf | 8.18261e-04 | White blood cell count | DC1MB_TMEM176A |\n",
       "\n"
      ],
      "text/plain": [
       "  parameter value       trait                  identifier    \n",
       "1 nsnps     2.46200e+03 White blood cell count DC1MB_TMEM176A\n",
       "2 PP.H0.abf 8.18261e-04 White blood cell count DC1MB_TMEM176A"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "head(eqtl_summary,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "28ebc623-2ba4-4382-95cb-d8b652ba881e",
   "metadata": {},
   "outputs": [],
   "source": [
    "## Extract amount of SNPS"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "79bafba6-9302-49ff-b9a3-caa818c18655",
   "metadata": {},
   "outputs": [],
   "source": [
    "n_snps = eqtl_summary[eqtl_summary$parameter == 'nsnps',]\n",
    "n_snps$overlapping_snps = n_snps$value\n",
    "n_snps$parameter = NULL\n",
    "n_snps$value = NULL"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "e5e7f024-b1fb-4e22-8828-cc3cf531de98",
   "metadata": {},
   "outputs": [],
   "source": [
    "#eqtl_summary = eqtl_summary[eqtl_summary$parameter != 'nsnps',]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "77624013-cc23-4fdb-bce3-b867be56b8ca",
   "metadata": {},
   "outputs": [],
   "source": [
    "## Extract cell-type, gene etc"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "d64fe822-3b10-476b-a132-a49ce34e5449",
   "metadata": {},
   "outputs": [],
   "source": [
    "eqtl_summary$cell_type = str_replace(eqtl_summary$identifier, '_.*', '')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "ad06f965-dc2e-42c2-aa1c-19ae04cfdadf",
   "metadata": {},
   "outputs": [],
   "source": [
    "eqtl_summary$gene = str_replace(eqtl_summary$identifier, '.*_', '')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "d5a3d03e-50d1-4429-a6ec-dd636f510609",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>\n",
       ".list-inline {list-style: none; margin:0; padding: 0}\n",
       ".list-inline>li {display: inline-block}\n",
       ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
       "</style>\n",
       "<ol class=list-inline><li>'DC1MB'</li><li>'B1MB'</li><li>'NK1MB'</li><li>'monocyte1MB'</li><li>'CD8T1MB'</li><li>'CD4T1MB'</li></ol>\n"
      ],
      "text/latex": [
       "\\begin{enumerate*}\n",
       "\\item 'DC1MB'\n",
       "\\item 'B1MB'\n",
       "\\item 'NK1MB'\n",
       "\\item 'monocyte1MB'\n",
       "\\item 'CD8T1MB'\n",
       "\\item 'CD4T1MB'\n",
       "\\end{enumerate*}\n"
      ],
      "text/markdown": [
       "1. 'DC1MB'\n",
       "2. 'B1MB'\n",
       "3. 'NK1MB'\n",
       "4. 'monocyte1MB'\n",
       "5. 'CD8T1MB'\n",
       "6. 'CD4T1MB'\n",
       "\n",
       "\n"
      ],
      "text/plain": [
       "[1] \"DC1MB\"       \"B1MB\"        \"NK1MB\"       \"monocyte1MB\" \"CD8T1MB\"    \n",
       "[6] \"CD4T1MB\"    "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "unique(eqtl_summary$cell_type)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "c7e6fc78-ac1a-451f-bc14-e6dce54f61cb",
   "metadata": {},
   "outputs": [],
   "source": [
    "## Add number of SNPS"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "7d80cf0c-4730-44b8-b678-50f3e5958a29",
   "metadata": {},
   "outputs": [],
   "source": [
    "eqtl_summary = merge(eqtl_summary, n_snps, by.x = c('trait', 'identifier'), by.y = c('trait', 'identifier'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "a5e3f9ca-c3d2-445e-ba82-ed242f6a01a3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 2 × 7</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>trait</th><th scope=col>identifier</th><th scope=col>parameter</th><th scope=col>value</th><th scope=col>cell_type</th><th scope=col>gene</th><th scope=col>overlapping_snps</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>1</th><td>Asthma</td><td>B1MB_HLA-DQA2</td><td>nsnps    </td><td>3.880000e+02</td><td>B1MB</td><td>HLA-DQA2</td><td>388</td></tr>\n",
       "\t<tr><th scope=row>2</th><td>Asthma</td><td>B1MB_HLA-DQA2</td><td>PP.H0.abf</td><td>1.212062e-25</td><td>B1MB</td><td>HLA-DQA2</td><td>388</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 2 × 7\n",
       "\\begin{tabular}{r|lllllll}\n",
       "  & trait & identifier & parameter & value & cell\\_type & gene & overlapping\\_snps\\\\\n",
       "  & <chr> & <chr> & <chr> & <dbl> & <chr> & <chr> & <dbl>\\\\\n",
       "\\hline\n",
       "\t1 & Asthma & B1MB\\_HLA-DQA2 & nsnps     & 3.880000e+02 & B1MB & HLA-DQA2 & 388\\\\\n",
       "\t2 & Asthma & B1MB\\_HLA-DQA2 & PP.H0.abf & 1.212062e-25 & B1MB & HLA-DQA2 & 388\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 2 × 7\n",
       "\n",
       "| <!--/--> | trait &lt;chr&gt; | identifier &lt;chr&gt; | parameter &lt;chr&gt; | value &lt;dbl&gt; | cell_type &lt;chr&gt; | gene &lt;chr&gt; | overlapping_snps &lt;dbl&gt; |\n",
       "|---|---|---|---|---|---|---|---|\n",
       "| 1 | Asthma | B1MB_HLA-DQA2 | nsnps     | 3.880000e+02 | B1MB | HLA-DQA2 | 388 |\n",
       "| 2 | Asthma | B1MB_HLA-DQA2 | PP.H0.abf | 1.212062e-25 | B1MB | HLA-DQA2 | 388 |\n",
       "\n"
      ],
      "text/plain": [
       "  trait  identifier    parameter value        cell_type gene    \n",
       "1 Asthma B1MB_HLA-DQA2 nsnps     3.880000e+02 B1MB      HLA-DQA2\n",
       "2 Asthma B1MB_HLA-DQA2 PP.H0.abf 1.212062e-25 B1MB      HLA-DQA2\n",
       "  overlapping_snps\n",
       "1 388             \n",
       "2 388             "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "head(eqtl_summary,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "b4dcc4f2-deb6-49d5-b737-6dab933a6f21",
   "metadata": {},
   "outputs": [],
   "source": [
    "### Maximum probability per identifier and trait"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "6fbce627-914d-4a99-a610-34fa11114dbd",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\u001b[1m\u001b[22m`summarise()` has grouped output by 'trait', 'identifier', 'cell_type'. You can\n",
      "override using the `.groups` argument.\n"
     ]
    }
   ],
   "source": [
    "max_prob = eqtl_summary[eqtl_summary$parameter != 'nsnps',] %>% group_by(trait, identifier, cell_type, gene) %>% summarise(value = max(value))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "e44b29b1-259b-4774-a6ba-3b32e7ffe47a",
   "metadata": {},
   "outputs": [],
   "source": [
    "eqtl_summary_filtered = merge(eqtl_summary, max_prob)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "79ab3696-b199-4999-a43b-40f08288fc43",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\u001b[1m\u001b[22m`summarise()` has grouped output by 'parameter'. You can override using the\n",
      "`.groups` argument.\n"
     ]
    }
   ],
   "source": [
    "overview_h_amounts = eqtl_summary_filtered %>% group_by(parameter, trait) %>% summarise(n = n(), mean_value = mean(value), amount_greater_0.9 = sum(value > 0.9), amount_greater_0.75 = sum(value > 0.75),amount_greater_0.5 = sum(value > 0.5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "42d9bc14-d39c-4514-8db8-c6a25d0ba778",
   "metadata": {},
   "outputs": [],
   "source": [
    "## Add snp information"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "418546a6-526f-4478-a6d5-75bd891fad4d",
   "metadata": {},
   "outputs": [],
   "source": [
    "n_snps = n_snps %>% group_by(trait) %>% summarise(average_overlapping_snps = mean(overlapping_snps), min_overlapping_snps = min(overlapping_snps), max_overlapping_snps = max(overlapping_snps))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "a6fd814e-abfd-4b2a-9857-23600340fe97",
   "metadata": {},
   "outputs": [],
   "source": [
    "#n_snps = unique(n_snps[,c('trait', 'overlapping_snps')])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "410c5391-6f89-4699-a0da-20eda9e82d37",
   "metadata": {},
   "outputs": [],
   "source": [
    "overview_h_amounts = merge(overview_h_amounts, n_snps, by.x = c('trait'), by.y = c('trait'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "bc03666e-598c-4ea1-a03f-042cd0136e4c",
   "metadata": {},
   "outputs": [],
   "source": [
    "#head(n_snps,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "2f7826aa-c5cf-4ddc-9745-1c1b72236235",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 5 × 10</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>trait</th><th scope=col>parameter</th><th scope=col>n</th><th scope=col>mean_value</th><th scope=col>amount_greater_0.9</th><th scope=col>amount_greater_0.75</th><th scope=col>amount_greater_0.5</th><th scope=col>average_overlapping_snps</th><th scope=col>min_overlapping_snps</th><th scope=col>max_overlapping_snps</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>26</th><td>White blood cell count</td><td>PP.H0.abf</td><td> 7</td><td>0.7627689</td><td> 0</td><td> 6</td><td> 7</td><td>1736.267</td><td> 517</td><td>2639</td></tr>\n",
       "\t<tr><th scope=row>27</th><td>White blood cell count</td><td>PP.H1.abf</td><td> 1</td><td>0.8050249</td><td> 0</td><td> 1</td><td> 1</td><td>1736.267</td><td> 517</td><td>2639</td></tr>\n",
       "\t<tr><th scope=row>28</th><td>White blood cell count</td><td>PP.H2.abf</td><td>17</td><td>0.9584354</td><td>16</td><td>17</td><td>17</td><td>1736.267</td><td> 517</td><td>2639</td></tr>\n",
       "\t<tr><th scope=row>29</th><td>White blood cell count</td><td>PP.H3.abf</td><td> 5</td><td>0.9526789</td><td> 4</td><td> 5</td><td> 5</td><td>1736.267</td><td> 517</td><td>2639</td></tr>\n",
       "\t<tr><th scope=row>23</th><td>Type_1_Diabetes       </td><td>PP.H3.abf</td><td>12</td><td>0.9998213</td><td>12</td><td>12</td><td>12</td><td>2284.000</td><td>1341</td><td>3161</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 5 × 10\n",
       "\\begin{tabular}{r|llllllllll}\n",
       "  & trait & parameter & n & mean\\_value & amount\\_greater\\_0.9 & amount\\_greater\\_0.75 & amount\\_greater\\_0.5 & average\\_overlapping\\_snps & min\\_overlapping\\_snps & max\\_overlapping\\_snps\\\\\n",
       "  & <chr> & <chr> & <int> & <dbl> & <int> & <int> & <int> & <dbl> & <dbl> & <dbl>\\\\\n",
       "\\hline\n",
       "\t26 & White blood cell count & PP.H0.abf &  7 & 0.7627689 &  0 &  6 &  7 & 1736.267 &  517 & 2639\\\\\n",
       "\t27 & White blood cell count & PP.H1.abf &  1 & 0.8050249 &  0 &  1 &  1 & 1736.267 &  517 & 2639\\\\\n",
       "\t28 & White blood cell count & PP.H2.abf & 17 & 0.9584354 & 16 & 17 & 17 & 1736.267 &  517 & 2639\\\\\n",
       "\t29 & White blood cell count & PP.H3.abf &  5 & 0.9526789 &  4 &  5 &  5 & 1736.267 &  517 & 2639\\\\\n",
       "\t23 & Type\\_1\\_Diabetes        & PP.H3.abf & 12 & 0.9998213 & 12 & 12 & 12 & 2284.000 & 1341 & 3161\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 5 × 10\n",
       "\n",
       "| <!--/--> | trait &lt;chr&gt; | parameter &lt;chr&gt; | n &lt;int&gt; | mean_value &lt;dbl&gt; | amount_greater_0.9 &lt;int&gt; | amount_greater_0.75 &lt;int&gt; | amount_greater_0.5 &lt;int&gt; | average_overlapping_snps &lt;dbl&gt; | min_overlapping_snps &lt;dbl&gt; | max_overlapping_snps &lt;dbl&gt; |\n",
       "|---|---|---|---|---|---|---|---|---|---|---|\n",
       "| 26 | White blood cell count | PP.H0.abf |  7 | 0.7627689 |  0 |  6 |  7 | 1736.267 |  517 | 2639 |\n",
       "| 27 | White blood cell count | PP.H1.abf |  1 | 0.8050249 |  0 |  1 |  1 | 1736.267 |  517 | 2639 |\n",
       "| 28 | White blood cell count | PP.H2.abf | 17 | 0.9584354 | 16 | 17 | 17 | 1736.267 |  517 | 2639 |\n",
       "| 29 | White blood cell count | PP.H3.abf |  5 | 0.9526789 |  4 |  5 |  5 | 1736.267 |  517 | 2639 |\n",
       "| 23 | Type_1_Diabetes        | PP.H3.abf | 12 | 0.9998213 | 12 | 12 | 12 | 2284.000 | 1341 | 3161 |\n",
       "\n"
      ],
      "text/plain": [
       "   trait                  parameter n  mean_value amount_greater_0.9\n",
       "26 White blood cell count PP.H0.abf  7 0.7627689   0                \n",
       "27 White blood cell count PP.H1.abf  1 0.8050249   0                \n",
       "28 White blood cell count PP.H2.abf 17 0.9584354  16                \n",
       "29 White blood cell count PP.H3.abf  5 0.9526789   4                \n",
       "23 Type_1_Diabetes        PP.H3.abf 12 0.9998213  12                \n",
       "   amount_greater_0.75 amount_greater_0.5 average_overlapping_snps\n",
       "26  6                   7                 1736.267                \n",
       "27  1                   1                 1736.267                \n",
       "28 17                  17                 1736.267                \n",
       "29  5                   5                 1736.267                \n",
       "23 12                  12                 2284.000                \n",
       "   min_overlapping_snps max_overlapping_snps\n",
       "26  517                 2639                \n",
       "27  517                 2639                \n",
       "28  517                 2639                \n",
       "29  517                 2639                \n",
       "23 1341                 3161                "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "head(overview_h_amounts[order(overview_h_amounts$trait, decreasing = TRUE),],5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "12afd501-1018-4ffd-a512-7ebca28dd146",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "61d3bee9-9b7d-4477-a8fe-8ad131aa3b8e",
   "metadata": {},
   "outputs": [],
   "source": [
    "### Inspect interesting hypothesis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "e88a2cfb-7f69-4f17-805e-87f8f4896b76",
   "metadata": {},
   "outputs": [],
   "source": [
    "parameter_var = 'PP.H4.abf'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "5dd1d320-92d1-48f6-a318-c8e90f782c6e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 29 × 7</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>trait</th><th scope=col>identifier</th><th scope=col>value</th><th scope=col>cell_type</th><th scope=col>gene</th><th scope=col>parameter</th><th scope=col>overlapping_snps</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>1</th><td>Asthma                    </td><td>B1MB_HLA-DQA2       </td><td>0.9997353</td><td>B1MB       </td><td>HLA-DQA2</td><td>PP.H4.abf</td><td> 388</td></tr>\n",
       "\t<tr><th scope=row>3</th><td>Asthma                    </td><td>B1MB_RPS26          </td><td>0.5349101</td><td>B1MB       </td><td>RPS26   </td><td>PP.H4.abf</td><td> 381</td></tr>\n",
       "\t<tr><th scope=row>6</th><td>Asthma                    </td><td>CD4T1MB_HLA-DQA2    </td><td>0.9999956</td><td>CD4T1MB    </td><td>HLA-DQA2</td><td>PP.H4.abf</td><td> 388</td></tr>\n",
       "\t<tr><th scope=row>8</th><td>Asthma                    </td><td>CD4T1MB_RPS26       </td><td>0.5349363</td><td>CD4T1MB    </td><td>RPS26   </td><td>PP.H4.abf</td><td> 381</td></tr>\n",
       "\t<tr><th scope=row>11</th><td>Asthma                    </td><td>CD8T1MB_HLA-DQA2    </td><td>1.0000000</td><td>CD8T1MB    </td><td>HLA-DQA2</td><td>PP.H4.abf</td><td> 388</td></tr>\n",
       "\t<tr><th scope=row>13</th><td>Asthma                    </td><td>CD8T1MB_RPS26       </td><td>0.5350001</td><td>CD8T1MB    </td><td>RPS26   </td><td>PP.H4.abf</td><td> 381</td></tr>\n",
       "\t<tr><th scope=row>16</th><td>Asthma                    </td><td>DC1MB_HLA-DQA2      </td><td>0.6589821</td><td>DC1MB      </td><td>HLA-DQA2</td><td>PP.H4.abf</td><td> 388</td></tr>\n",
       "\t<tr><th scope=row>18</th><td>Asthma                    </td><td>DC1MB_RPS26         </td><td>0.5349096</td><td>DC1MB      </td><td>RPS26   </td><td>PP.H4.abf</td><td> 381</td></tr>\n",
       "\t<tr><th scope=row>21</th><td>Asthma                    </td><td>monocyte1MB_HLA-DQA2</td><td>0.9746826</td><td>monocyte1MB</td><td>HLA-DQA2</td><td>PP.H4.abf</td><td> 388</td></tr>\n",
       "\t<tr><th scope=row>23</th><td>Asthma                    </td><td>monocyte1MB_RPS26   </td><td>0.5349095</td><td>monocyte1MB</td><td>RPS26   </td><td>PP.H4.abf</td><td> 381</td></tr>\n",
       "\t<tr><th scope=row>26</th><td>Asthma                    </td><td>NK1MB_HLA-DQA2      </td><td>0.9999953</td><td>NK1MB      </td><td>HLA-DQA2</td><td>PP.H4.abf</td><td> 388</td></tr>\n",
       "\t<tr><th scope=row>28</th><td>Asthma                    </td><td>NK1MB_RPS26         </td><td>0.5429194</td><td>NK1MB      </td><td>RPS26   </td><td>PP.H4.abf</td><td> 381</td></tr>\n",
       "\t<tr><th scope=row>37</th><td>Crohn's Disease           </td><td>CD4T1MB_RNASET2     </td><td>0.9046377</td><td>CD4T1MB    </td><td>RNASET2 </td><td>PP.H4.abf</td><td>2707</td></tr>\n",
       "\t<tr><th scope=row>42</th><td>Crohn's Disease           </td><td>CD8T1MB_RNASET2     </td><td>0.5453104</td><td>CD8T1MB    </td><td>RNASET2 </td><td>PP.H4.abf</td><td>2707</td></tr>\n",
       "\t<tr><th scope=row>67</th><td>Inflammatory Bowel Disease</td><td>CD4T1MB_RNASET2     </td><td>0.9309073</td><td>CD4T1MB    </td><td>RNASET2 </td><td>PP.H4.abf</td><td>2704</td></tr>\n",
       "\t<tr><th scope=row>91</th><td>Multiple Sclerosis        </td><td>B1MB_HLA-DQA2       </td><td>0.9999979</td><td>B1MB       </td><td>HLA-DQA2</td><td>PP.H4.abf</td><td>  50</td></tr>\n",
       "\t<tr><th scope=row>96</th><td>Multiple Sclerosis        </td><td>CD4T1MB_HLA-DQA2    </td><td>0.7868654</td><td>CD4T1MB    </td><td>HLA-DQA2</td><td>PP.H4.abf</td><td>  50</td></tr>\n",
       "\t<tr><th scope=row>101</th><td>Multiple Sclerosis        </td><td>CD8T1MB_HLA-DQA2    </td><td>0.9978392</td><td>CD8T1MB    </td><td>HLA-DQA2</td><td>PP.H4.abf</td><td>  50</td></tr>\n",
       "\t<tr><th scope=row>106</th><td>Multiple Sclerosis        </td><td>DC1MB_HLA-DQA2      </td><td>0.9999978</td><td>DC1MB      </td><td>HLA-DQA2</td><td>PP.H4.abf</td><td>  50</td></tr>\n",
       "\t<tr><th scope=row>111</th><td>Multiple Sclerosis        </td><td>monocyte1MB_HLA-DQA2</td><td>0.9999995</td><td>monocyte1MB</td><td>HLA-DQA2</td><td>PP.H4.abf</td><td>  50</td></tr>\n",
       "\t<tr><th scope=row>121</th><td>Rheumatoid Arthritis      </td><td>B1MB_HLA-DQA2       </td><td>0.6648626</td><td>B1MB       </td><td>HLA-DQA2</td><td>PP.H4.abf</td><td> 834</td></tr>\n",
       "\t<tr><th scope=row>123</th><td>Rheumatoid Arthritis      </td><td>B1MB_RPS26          </td><td>0.7520723</td><td>B1MB       </td><td>RPS26   </td><td>PP.H4.abf</td><td> 882</td></tr>\n",
       "\t<tr><th scope=row>128</th><td>Rheumatoid Arthritis      </td><td>CD4T1MB_RPS26       </td><td>0.7536740</td><td>CD4T1MB    </td><td>RPS26   </td><td>PP.H4.abf</td><td> 882</td></tr>\n",
       "\t<tr><th scope=row>133</th><td>Rheumatoid Arthritis      </td><td>CD8T1MB_RPS26       </td><td>0.7532601</td><td>CD8T1MB    </td><td>RPS26   </td><td>PP.H4.abf</td><td> 882</td></tr>\n",
       "\t<tr><th scope=row>136</th><td>Rheumatoid Arthritis      </td><td>DC1MB_HLA-DQA2      </td><td>0.6717926</td><td>DC1MB      </td><td>HLA-DQA2</td><td>PP.H4.abf</td><td> 834</td></tr>\n",
       "\t<tr><th scope=row>138</th><td>Rheumatoid Arthritis      </td><td>DC1MB_RPS26         </td><td>0.7534094</td><td>DC1MB      </td><td>RPS26   </td><td>PP.H4.abf</td><td> 882</td></tr>\n",
       "\t<tr><th scope=row>141</th><td>Rheumatoid Arthritis      </td><td>monocyte1MB_HLA-DQA2</td><td>0.6669792</td><td>monocyte1MB</td><td>HLA-DQA2</td><td>PP.H4.abf</td><td> 834</td></tr>\n",
       "\t<tr><th scope=row>143</th><td>Rheumatoid Arthritis      </td><td>monocyte1MB_RPS26   </td><td>0.7551725</td><td>monocyte1MB</td><td>RPS26   </td><td>PP.H4.abf</td><td> 882</td></tr>\n",
       "\t<tr><th scope=row>148</th><td>Rheumatoid Arthritis      </td><td>NK1MB_RPS26         </td><td>0.7545729</td><td>NK1MB      </td><td>RPS26   </td><td>PP.H4.abf</td><td> 882</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 29 × 7\n",
       "\\begin{tabular}{r|lllllll}\n",
       "  & trait & identifier & value & cell\\_type & gene & parameter & overlapping\\_snps\\\\\n",
       "  & <chr> & <chr> & <dbl> & <chr> & <chr> & <chr> & <dbl>\\\\\n",
       "\\hline\n",
       "\t1 & Asthma                     & B1MB\\_HLA-DQA2        & 0.9997353 & B1MB        & HLA-DQA2 & PP.H4.abf &  388\\\\\n",
       "\t3 & Asthma                     & B1MB\\_RPS26           & 0.5349101 & B1MB        & RPS26    & PP.H4.abf &  381\\\\\n",
       "\t6 & Asthma                     & CD4T1MB\\_HLA-DQA2     & 0.9999956 & CD4T1MB     & HLA-DQA2 & PP.H4.abf &  388\\\\\n",
       "\t8 & Asthma                     & CD4T1MB\\_RPS26        & 0.5349363 & CD4T1MB     & RPS26    & PP.H4.abf &  381\\\\\n",
       "\t11 & Asthma                     & CD8T1MB\\_HLA-DQA2     & 1.0000000 & CD8T1MB     & HLA-DQA2 & PP.H4.abf &  388\\\\\n",
       "\t13 & Asthma                     & CD8T1MB\\_RPS26        & 0.5350001 & CD8T1MB     & RPS26    & PP.H4.abf &  381\\\\\n",
       "\t16 & Asthma                     & DC1MB\\_HLA-DQA2       & 0.6589821 & DC1MB       & HLA-DQA2 & PP.H4.abf &  388\\\\\n",
       "\t18 & Asthma                     & DC1MB\\_RPS26          & 0.5349096 & DC1MB       & RPS26    & PP.H4.abf &  381\\\\\n",
       "\t21 & Asthma                     & monocyte1MB\\_HLA-DQA2 & 0.9746826 & monocyte1MB & HLA-DQA2 & PP.H4.abf &  388\\\\\n",
       "\t23 & Asthma                     & monocyte1MB\\_RPS26    & 0.5349095 & monocyte1MB & RPS26    & PP.H4.abf &  381\\\\\n",
       "\t26 & Asthma                     & NK1MB\\_HLA-DQA2       & 0.9999953 & NK1MB       & HLA-DQA2 & PP.H4.abf &  388\\\\\n",
       "\t28 & Asthma                     & NK1MB\\_RPS26          & 0.5429194 & NK1MB       & RPS26    & PP.H4.abf &  381\\\\\n",
       "\t37 & Crohn's Disease            & CD4T1MB\\_RNASET2      & 0.9046377 & CD4T1MB     & RNASET2  & PP.H4.abf & 2707\\\\\n",
       "\t42 & Crohn's Disease            & CD8T1MB\\_RNASET2      & 0.5453104 & CD8T1MB     & RNASET2  & PP.H4.abf & 2707\\\\\n",
       "\t67 & Inflammatory Bowel Disease & CD4T1MB\\_RNASET2      & 0.9309073 & CD4T1MB     & RNASET2  & PP.H4.abf & 2704\\\\\n",
       "\t91 & Multiple Sclerosis         & B1MB\\_HLA-DQA2        & 0.9999979 & B1MB        & HLA-DQA2 & PP.H4.abf &   50\\\\\n",
       "\t96 & Multiple Sclerosis         & CD4T1MB\\_HLA-DQA2     & 0.7868654 & CD4T1MB     & HLA-DQA2 & PP.H4.abf &   50\\\\\n",
       "\t101 & Multiple Sclerosis         & CD8T1MB\\_HLA-DQA2     & 0.9978392 & CD8T1MB     & HLA-DQA2 & PP.H4.abf &   50\\\\\n",
       "\t106 & Multiple Sclerosis         & DC1MB\\_HLA-DQA2       & 0.9999978 & DC1MB       & HLA-DQA2 & PP.H4.abf &   50\\\\\n",
       "\t111 & Multiple Sclerosis         & monocyte1MB\\_HLA-DQA2 & 0.9999995 & monocyte1MB & HLA-DQA2 & PP.H4.abf &   50\\\\\n",
       "\t121 & Rheumatoid Arthritis       & B1MB\\_HLA-DQA2        & 0.6648626 & B1MB        & HLA-DQA2 & PP.H4.abf &  834\\\\\n",
       "\t123 & Rheumatoid Arthritis       & B1MB\\_RPS26           & 0.7520723 & B1MB        & RPS26    & PP.H4.abf &  882\\\\\n",
       "\t128 & Rheumatoid Arthritis       & CD4T1MB\\_RPS26        & 0.7536740 & CD4T1MB     & RPS26    & PP.H4.abf &  882\\\\\n",
       "\t133 & Rheumatoid Arthritis       & CD8T1MB\\_RPS26        & 0.7532601 & CD8T1MB     & RPS26    & PP.H4.abf &  882\\\\\n",
       "\t136 & Rheumatoid Arthritis       & DC1MB\\_HLA-DQA2       & 0.6717926 & DC1MB       & HLA-DQA2 & PP.H4.abf &  834\\\\\n",
       "\t138 & Rheumatoid Arthritis       & DC1MB\\_RPS26          & 0.7534094 & DC1MB       & RPS26    & PP.H4.abf &  882\\\\\n",
       "\t141 & Rheumatoid Arthritis       & monocyte1MB\\_HLA-DQA2 & 0.6669792 & monocyte1MB & HLA-DQA2 & PP.H4.abf &  834\\\\\n",
       "\t143 & Rheumatoid Arthritis       & monocyte1MB\\_RPS26    & 0.7551725 & monocyte1MB & RPS26    & PP.H4.abf &  882\\\\\n",
       "\t148 & Rheumatoid Arthritis       & NK1MB\\_RPS26          & 0.7545729 & NK1MB       & RPS26    & PP.H4.abf &  882\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 29 × 7\n",
       "\n",
       "| <!--/--> | trait &lt;chr&gt; | identifier &lt;chr&gt; | value &lt;dbl&gt; | cell_type &lt;chr&gt; | gene &lt;chr&gt; | parameter &lt;chr&gt; | overlapping_snps &lt;dbl&gt; |\n",
       "|---|---|---|---|---|---|---|---|\n",
       "| 1 | Asthma                     | B1MB_HLA-DQA2        | 0.9997353 | B1MB        | HLA-DQA2 | PP.H4.abf |  388 |\n",
       "| 3 | Asthma                     | B1MB_RPS26           | 0.5349101 | B1MB        | RPS26    | PP.H4.abf |  381 |\n",
       "| 6 | Asthma                     | CD4T1MB_HLA-DQA2     | 0.9999956 | CD4T1MB     | HLA-DQA2 | PP.H4.abf |  388 |\n",
       "| 8 | Asthma                     | CD4T1MB_RPS26        | 0.5349363 | CD4T1MB     | RPS26    | PP.H4.abf |  381 |\n",
       "| 11 | Asthma                     | CD8T1MB_HLA-DQA2     | 1.0000000 | CD8T1MB     | HLA-DQA2 | PP.H4.abf |  388 |\n",
       "| 13 | Asthma                     | CD8T1MB_RPS26        | 0.5350001 | CD8T1MB     | RPS26    | PP.H4.abf |  381 |\n",
       "| 16 | Asthma                     | DC1MB_HLA-DQA2       | 0.6589821 | DC1MB       | HLA-DQA2 | PP.H4.abf |  388 |\n",
       "| 18 | Asthma                     | DC1MB_RPS26          | 0.5349096 | DC1MB       | RPS26    | PP.H4.abf |  381 |\n",
       "| 21 | Asthma                     | monocyte1MB_HLA-DQA2 | 0.9746826 | monocyte1MB | HLA-DQA2 | PP.H4.abf |  388 |\n",
       "| 23 | Asthma                     | monocyte1MB_RPS26    | 0.5349095 | monocyte1MB | RPS26    | PP.H4.abf |  381 |\n",
       "| 26 | Asthma                     | NK1MB_HLA-DQA2       | 0.9999953 | NK1MB       | HLA-DQA2 | PP.H4.abf |  388 |\n",
       "| 28 | Asthma                     | NK1MB_RPS26          | 0.5429194 | NK1MB       | RPS26    | PP.H4.abf |  381 |\n",
       "| 37 | Crohn's Disease            | CD4T1MB_RNASET2      | 0.9046377 | CD4T1MB     | RNASET2  | PP.H4.abf | 2707 |\n",
       "| 42 | Crohn's Disease            | CD8T1MB_RNASET2      | 0.5453104 | CD8T1MB     | RNASET2  | PP.H4.abf | 2707 |\n",
       "| 67 | Inflammatory Bowel Disease | CD4T1MB_RNASET2      | 0.9309073 | CD4T1MB     | RNASET2  | PP.H4.abf | 2704 |\n",
       "| 91 | Multiple Sclerosis         | B1MB_HLA-DQA2        | 0.9999979 | B1MB        | HLA-DQA2 | PP.H4.abf |   50 |\n",
       "| 96 | Multiple Sclerosis         | CD4T1MB_HLA-DQA2     | 0.7868654 | CD4T1MB     | HLA-DQA2 | PP.H4.abf |   50 |\n",
       "| 101 | Multiple Sclerosis         | CD8T1MB_HLA-DQA2     | 0.9978392 | CD8T1MB     | HLA-DQA2 | PP.H4.abf |   50 |\n",
       "| 106 | Multiple Sclerosis         | DC1MB_HLA-DQA2       | 0.9999978 | DC1MB       | HLA-DQA2 | PP.H4.abf |   50 |\n",
       "| 111 | Multiple Sclerosis         | monocyte1MB_HLA-DQA2 | 0.9999995 | monocyte1MB | HLA-DQA2 | PP.H4.abf |   50 |\n",
       "| 121 | Rheumatoid Arthritis       | B1MB_HLA-DQA2        | 0.6648626 | B1MB        | HLA-DQA2 | PP.H4.abf |  834 |\n",
       "| 123 | Rheumatoid Arthritis       | B1MB_RPS26           | 0.7520723 | B1MB        | RPS26    | PP.H4.abf |  882 |\n",
       "| 128 | Rheumatoid Arthritis       | CD4T1MB_RPS26        | 0.7536740 | CD4T1MB     | RPS26    | PP.H4.abf |  882 |\n",
       "| 133 | Rheumatoid Arthritis       | CD8T1MB_RPS26        | 0.7532601 | CD8T1MB     | RPS26    | PP.H4.abf |  882 |\n",
       "| 136 | Rheumatoid Arthritis       | DC1MB_HLA-DQA2       | 0.6717926 | DC1MB       | HLA-DQA2 | PP.H4.abf |  834 |\n",
       "| 138 | Rheumatoid Arthritis       | DC1MB_RPS26          | 0.7534094 | DC1MB       | RPS26    | PP.H4.abf |  882 |\n",
       "| 141 | Rheumatoid Arthritis       | monocyte1MB_HLA-DQA2 | 0.6669792 | monocyte1MB | HLA-DQA2 | PP.H4.abf |  834 |\n",
       "| 143 | Rheumatoid Arthritis       | monocyte1MB_RPS26    | 0.7551725 | monocyte1MB | RPS26    | PP.H4.abf |  882 |\n",
       "| 148 | Rheumatoid Arthritis       | NK1MB_RPS26          | 0.7545729 | NK1MB       | RPS26    | PP.H4.abf |  882 |\n",
       "\n"
      ],
      "text/plain": [
       "    trait                      identifier           value     cell_type  \n",
       "1   Asthma                     B1MB_HLA-DQA2        0.9997353 B1MB       \n",
       "3   Asthma                     B1MB_RPS26           0.5349101 B1MB       \n",
       "6   Asthma                     CD4T1MB_HLA-DQA2     0.9999956 CD4T1MB    \n",
       "8   Asthma                     CD4T1MB_RPS26        0.5349363 CD4T1MB    \n",
       "11  Asthma                     CD8T1MB_HLA-DQA2     1.0000000 CD8T1MB    \n",
       "13  Asthma                     CD8T1MB_RPS26        0.5350001 CD8T1MB    \n",
       "16  Asthma                     DC1MB_HLA-DQA2       0.6589821 DC1MB      \n",
       "18  Asthma                     DC1MB_RPS26          0.5349096 DC1MB      \n",
       "21  Asthma                     monocyte1MB_HLA-DQA2 0.9746826 monocyte1MB\n",
       "23  Asthma                     monocyte1MB_RPS26    0.5349095 monocyte1MB\n",
       "26  Asthma                     NK1MB_HLA-DQA2       0.9999953 NK1MB      \n",
       "28  Asthma                     NK1MB_RPS26          0.5429194 NK1MB      \n",
       "37  Crohn's Disease            CD4T1MB_RNASET2      0.9046377 CD4T1MB    \n",
       "42  Crohn's Disease            CD8T1MB_RNASET2      0.5453104 CD8T1MB    \n",
       "67  Inflammatory Bowel Disease CD4T1MB_RNASET2      0.9309073 CD4T1MB    \n",
       "91  Multiple Sclerosis         B1MB_HLA-DQA2        0.9999979 B1MB       \n",
       "96  Multiple Sclerosis         CD4T1MB_HLA-DQA2     0.7868654 CD4T1MB    \n",
       "101 Multiple Sclerosis         CD8T1MB_HLA-DQA2     0.9978392 CD8T1MB    \n",
       "106 Multiple Sclerosis         DC1MB_HLA-DQA2       0.9999978 DC1MB      \n",
       "111 Multiple Sclerosis         monocyte1MB_HLA-DQA2 0.9999995 monocyte1MB\n",
       "121 Rheumatoid Arthritis       B1MB_HLA-DQA2        0.6648626 B1MB       \n",
       "123 Rheumatoid Arthritis       B1MB_RPS26           0.7520723 B1MB       \n",
       "128 Rheumatoid Arthritis       CD4T1MB_RPS26        0.7536740 CD4T1MB    \n",
       "133 Rheumatoid Arthritis       CD8T1MB_RPS26        0.7532601 CD8T1MB    \n",
       "136 Rheumatoid Arthritis       DC1MB_HLA-DQA2       0.6717926 DC1MB      \n",
       "138 Rheumatoid Arthritis       DC1MB_RPS26          0.7534094 DC1MB      \n",
       "141 Rheumatoid Arthritis       monocyte1MB_HLA-DQA2 0.6669792 monocyte1MB\n",
       "143 Rheumatoid Arthritis       monocyte1MB_RPS26    0.7551725 monocyte1MB\n",
       "148 Rheumatoid Arthritis       NK1MB_RPS26          0.7545729 NK1MB      \n",
       "    gene     parameter overlapping_snps\n",
       "1   HLA-DQA2 PP.H4.abf  388            \n",
       "3   RPS26    PP.H4.abf  381            \n",
       "6   HLA-DQA2 PP.H4.abf  388            \n",
       "8   RPS26    PP.H4.abf  381            \n",
       "11  HLA-DQA2 PP.H4.abf  388            \n",
       "13  RPS26    PP.H4.abf  381            \n",
       "16  HLA-DQA2 PP.H4.abf  388            \n",
       "18  RPS26    PP.H4.abf  381            \n",
       "21  HLA-DQA2 PP.H4.abf  388            \n",
       "23  RPS26    PP.H4.abf  381            \n",
       "26  HLA-DQA2 PP.H4.abf  388            \n",
       "28  RPS26    PP.H4.abf  381            \n",
       "37  RNASET2  PP.H4.abf 2707            \n",
       "42  RNASET2  PP.H4.abf 2707            \n",
       "67  RNASET2  PP.H4.abf 2704            \n",
       "91  HLA-DQA2 PP.H4.abf   50            \n",
       "96  HLA-DQA2 PP.H4.abf   50            \n",
       "101 HLA-DQA2 PP.H4.abf   50            \n",
       "106 HLA-DQA2 PP.H4.abf   50            \n",
       "111 HLA-DQA2 PP.H4.abf   50            \n",
       "121 HLA-DQA2 PP.H4.abf  834            \n",
       "123 RPS26    PP.H4.abf  882            \n",
       "128 RPS26    PP.H4.abf  882            \n",
       "133 RPS26    PP.H4.abf  882            \n",
       "136 HLA-DQA2 PP.H4.abf  834            \n",
       "138 RPS26    PP.H4.abf  882            \n",
       "141 HLA-DQA2 PP.H4.abf  834            \n",
       "143 RPS26    PP.H4.abf  882            \n",
       "148 RPS26    PP.H4.abf  882            "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "eqtl_summary_filtered[(eqtl_summary_filtered$parameter == parameter_var) ,]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "511df027-bdf8-45d0-9e06-c789a47a810a",
   "metadata": {},
   "outputs": [],
   "source": [
    "parameter_var = 'PP.H3.abf'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "663e5826-d961-4933-ba17-d2096e8b1b37",
   "metadata": {},
   "outputs": [],
   "source": [
    "#trait = c('Rheumatoid Arthritis', 'Type_1_Diabetes', 'Crohn\\'s Disease')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "3656aff9-7838-4c4e-86c8-a2fcfe9b558c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 38 × 7</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>trait</th><th scope=col>identifier</th><th scope=col>value</th><th scope=col>cell_type</th><th scope=col>gene</th><th scope=col>parameter</th><th scope=col>overlapping_snps</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>31</th><td>Crohn's Disease           </td><td>B1MB_HLA-DQA2       </td><td>0.9999567</td><td>B1MB       </td><td>HLA-DQA2</td><td>PP.H3.abf</td><td>4698</td></tr>\n",
       "\t<tr><th scope=row>36</th><td>Crohn's Disease           </td><td>CD4T1MB_HLA-DQA2    </td><td>0.9998617</td><td>CD4T1MB    </td><td>HLA-DQA2</td><td>PP.H3.abf</td><td>4698</td></tr>\n",
       "\t<tr><th scope=row>41</th><td>Crohn's Disease           </td><td>CD8T1MB_HLA-DQA2    </td><td>0.9995537</td><td>CD8T1MB    </td><td>HLA-DQA2</td><td>PP.H3.abf</td><td>4698</td></tr>\n",
       "\t<tr><th scope=row>46</th><td>Crohn's Disease           </td><td>DC1MB_HLA-DQA2      </td><td>0.9999567</td><td>DC1MB      </td><td>HLA-DQA2</td><td>PP.H3.abf</td><td>4698</td></tr>\n",
       "\t<tr><th scope=row>51</th><td>Crohn's Disease           </td><td>monocyte1MB_HLA-DQA2</td><td>0.9999567</td><td>monocyte1MB</td><td>HLA-DQA2</td><td>PP.H3.abf</td><td>4698</td></tr>\n",
       "\t<tr><th scope=row>56</th><td>Crohn's Disease           </td><td>NK1MB_HLA-DQA2      </td><td>0.9998702</td><td>NK1MB      </td><td>HLA-DQA2</td><td>PP.H3.abf</td><td>4698</td></tr>\n",
       "\t<tr><th scope=row>57</th><td>Crohn's Disease           </td><td>NK1MB_RNASET2       </td><td>0.5016812</td><td>NK1MB      </td><td>RNASET2 </td><td>PP.H3.abf</td><td>2707</td></tr>\n",
       "\t<tr><th scope=row>61</th><td>Inflammatory Bowel Disease</td><td>B1MB_HLA-DQA2       </td><td>0.9263285</td><td>B1MB       </td><td>HLA-DQA2</td><td>PP.H3.abf</td><td>4700</td></tr>\n",
       "\t<tr><th scope=row>66</th><td>Inflammatory Bowel Disease</td><td>CD4T1MB_HLA-DQA2    </td><td>0.8770284</td><td>CD4T1MB    </td><td>HLA-DQA2</td><td>PP.H3.abf</td><td>4700</td></tr>\n",
       "\t<tr><th scope=row>71</th><td>Inflammatory Bowel Disease</td><td>CD8T1MB_HLA-DQA2    </td><td>0.9360076</td><td>CD8T1MB    </td><td>HLA-DQA2</td><td>PP.H3.abf</td><td>4700</td></tr>\n",
       "\t<tr><th scope=row>72</th><td>Inflammatory Bowel Disease</td><td>CD8T1MB_RNASET2     </td><td>0.6274067</td><td>CD8T1MB    </td><td>RNASET2 </td><td>PP.H3.abf</td><td>2704</td></tr>\n",
       "\t<tr><th scope=row>76</th><td>Inflammatory Bowel Disease</td><td>DC1MB_HLA-DQA2      </td><td>0.9242179</td><td>DC1MB      </td><td>HLA-DQA2</td><td>PP.H3.abf</td><td>4700</td></tr>\n",
       "\t<tr><th scope=row>81</th><td>Inflammatory Bowel Disease</td><td>monocyte1MB_HLA-DQA2</td><td>0.9066889</td><td>monocyte1MB</td><td>HLA-DQA2</td><td>PP.H3.abf</td><td>4700</td></tr>\n",
       "\t<tr><th scope=row>86</th><td>Inflammatory Bowel Disease</td><td>NK1MB_HLA-DQA2      </td><td>0.9820401</td><td>NK1MB      </td><td>HLA-DQA2</td><td>PP.H3.abf</td><td>4700</td></tr>\n",
       "\t<tr><th scope=row>87</th><td>Inflammatory Bowel Disease</td><td>NK1MB_RNASET2       </td><td>0.4851461</td><td>NK1MB      </td><td>RNASET2 </td><td>PP.H3.abf</td><td>2704</td></tr>\n",
       "\t<tr><th scope=row>126</th><td>Rheumatoid Arthritis      </td><td>CD4T1MB_HLA-DQA2    </td><td>0.6547936</td><td>CD4T1MB    </td><td>HLA-DQA2</td><td>PP.H3.abf</td><td> 834</td></tr>\n",
       "\t<tr><th scope=row>127</th><td>Rheumatoid Arthritis      </td><td>CD4T1MB_RNASET2     </td><td>1.0000000</td><td>CD4T1MB    </td><td>RNASET2 </td><td>PP.H3.abf</td><td>2031</td></tr>\n",
       "\t<tr><th scope=row>131</th><td>Rheumatoid Arthritis      </td><td>CD8T1MB_HLA-DQA2    </td><td>0.7767070</td><td>CD8T1MB    </td><td>HLA-DQA2</td><td>PP.H3.abf</td><td> 834</td></tr>\n",
       "\t<tr><th scope=row>132</th><td>Rheumatoid Arthritis      </td><td>CD8T1MB_RNASET2     </td><td>0.9994734</td><td>CD8T1MB    </td><td>RNASET2 </td><td>PP.H3.abf</td><td>2031</td></tr>\n",
       "\t<tr><th scope=row>146</th><td>Rheumatoid Arthritis      </td><td>NK1MB_HLA-DQA2      </td><td>0.6625783</td><td>NK1MB      </td><td>HLA-DQA2</td><td>PP.H3.abf</td><td> 834</td></tr>\n",
       "\t<tr><th scope=row>147</th><td>Rheumatoid Arthritis      </td><td>NK1MB_RNASET2       </td><td>0.7544265</td><td>NK1MB      </td><td>RNASET2 </td><td>PP.H3.abf</td><td>2031</td></tr>\n",
       "\t<tr><th scope=row>151</th><td>Type_1_Diabetes           </td><td>B1MB_HLA-DQA2       </td><td>1.0000000</td><td>B1MB       </td><td>HLA-DQA2</td><td>PP.H3.abf</td><td>1344</td></tr>\n",
       "\t<tr><th scope=row>153</th><td>Type_1_Diabetes           </td><td>B1MB_RPS26          </td><td>0.9998778</td><td>B1MB       </td><td>RPS26   </td><td>PP.H3.abf</td><td>1341</td></tr>\n",
       "\t<tr><th scope=row>156</th><td>Type_1_Diabetes           </td><td>CD4T1MB_HLA-DQA2    </td><td>0.9995561</td><td>CD4T1MB    </td><td>HLA-DQA2</td><td>PP.H3.abf</td><td>1344</td></tr>\n",
       "\t<tr><th scope=row>158</th><td>Type_1_Diabetes           </td><td>CD4T1MB_RPS26       </td><td>0.9997676</td><td>CD4T1MB    </td><td>RPS26   </td><td>PP.H3.abf</td><td>1341</td></tr>\n",
       "\t<tr><th scope=row>161</th><td>Type_1_Diabetes           </td><td>CD8T1MB_HLA-DQA2    </td><td>1.0000000</td><td>CD8T1MB    </td><td>HLA-DQA2</td><td>PP.H3.abf</td><td>1344</td></tr>\n",
       "\t<tr><th scope=row>163</th><td>Type_1_Diabetes           </td><td>CD8T1MB_RPS26       </td><td>0.9995874</td><td>CD8T1MB    </td><td>RPS26   </td><td>PP.H3.abf</td><td>1341</td></tr>\n",
       "\t<tr><th scope=row>166</th><td>Type_1_Diabetes           </td><td>DC1MB_HLA-DQA2      </td><td>1.0000000</td><td>DC1MB      </td><td>HLA-DQA2</td><td>PP.H3.abf</td><td>1344</td></tr>\n",
       "\t<tr><th scope=row>168</th><td>Type_1_Diabetes           </td><td>DC1MB_RPS26         </td><td>0.9995863</td><td>DC1MB      </td><td>RPS26   </td><td>PP.H3.abf</td><td>1341</td></tr>\n",
       "\t<tr><th scope=row>171</th><td>Type_1_Diabetes           </td><td>monocyte1MB_HLA-DQA2</td><td>1.0000000</td><td>monocyte1MB</td><td>HLA-DQA2</td><td>PP.H3.abf</td><td>1344</td></tr>\n",
       "\t<tr><th scope=row>173</th><td>Type_1_Diabetes           </td><td>monocyte1MB_RPS26   </td><td>0.9998459</td><td>monocyte1MB</td><td>RPS26   </td><td>PP.H3.abf</td><td>1341</td></tr>\n",
       "\t<tr><th scope=row>176</th><td>Type_1_Diabetes           </td><td>NK1MB_HLA-DQA2      </td><td>0.9999993</td><td>NK1MB      </td><td>HLA-DQA2</td><td>PP.H3.abf</td><td>1344</td></tr>\n",
       "\t<tr><th scope=row>178</th><td>Type_1_Diabetes           </td><td>NK1MB_RPS26         </td><td>0.9996350</td><td>NK1MB      </td><td>RPS26   </td><td>PP.H3.abf</td><td>1341</td></tr>\n",
       "\t<tr><th scope=row>181</th><td>White blood cell count    </td><td>B1MB_HLA-DQA2       </td><td>1.0000000</td><td>B1MB       </td><td>HLA-DQA2</td><td>PP.H3.abf</td><td> 517</td></tr>\n",
       "\t<tr><th scope=row>186</th><td>White blood cell count    </td><td>CD4T1MB_HLA-DQA2    </td><td>0.7634488</td><td>CD4T1MB    </td><td>HLA-DQA2</td><td>PP.H3.abf</td><td> 517</td></tr>\n",
       "\t<tr><th scope=row>191</th><td>White blood cell count    </td><td>CD8T1MB_HLA-DQA2    </td><td>0.9999464</td><td>CD8T1MB    </td><td>HLA-DQA2</td><td>PP.H3.abf</td><td> 517</td></tr>\n",
       "\t<tr><th scope=row>196</th><td>White blood cell count    </td><td>DC1MB_HLA-DQA2      </td><td>1.0000000</td><td>DC1MB      </td><td>HLA-DQA2</td><td>PP.H3.abf</td><td> 517</td></tr>\n",
       "\t<tr><th scope=row>201</th><td>White blood cell count    </td><td>monocyte1MB_HLA-DQA2</td><td>0.9999996</td><td>monocyte1MB</td><td>HLA-DQA2</td><td>PP.H3.abf</td><td> 517</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 38 × 7\n",
       "\\begin{tabular}{r|lllllll}\n",
       "  & trait & identifier & value & cell\\_type & gene & parameter & overlapping\\_snps\\\\\n",
       "  & <chr> & <chr> & <dbl> & <chr> & <chr> & <chr> & <dbl>\\\\\n",
       "\\hline\n",
       "\t31 & Crohn's Disease            & B1MB\\_HLA-DQA2        & 0.9999567 & B1MB        & HLA-DQA2 & PP.H3.abf & 4698\\\\\n",
       "\t36 & Crohn's Disease            & CD4T1MB\\_HLA-DQA2     & 0.9998617 & CD4T1MB     & HLA-DQA2 & PP.H3.abf & 4698\\\\\n",
       "\t41 & Crohn's Disease            & CD8T1MB\\_HLA-DQA2     & 0.9995537 & CD8T1MB     & HLA-DQA2 & PP.H3.abf & 4698\\\\\n",
       "\t46 & Crohn's Disease            & DC1MB\\_HLA-DQA2       & 0.9999567 & DC1MB       & HLA-DQA2 & PP.H3.abf & 4698\\\\\n",
       "\t51 & Crohn's Disease            & monocyte1MB\\_HLA-DQA2 & 0.9999567 & monocyte1MB & HLA-DQA2 & PP.H3.abf & 4698\\\\\n",
       "\t56 & Crohn's Disease            & NK1MB\\_HLA-DQA2       & 0.9998702 & NK1MB       & HLA-DQA2 & PP.H3.abf & 4698\\\\\n",
       "\t57 & Crohn's Disease            & NK1MB\\_RNASET2        & 0.5016812 & NK1MB       & RNASET2  & PP.H3.abf & 2707\\\\\n",
       "\t61 & Inflammatory Bowel Disease & B1MB\\_HLA-DQA2        & 0.9263285 & B1MB        & HLA-DQA2 & PP.H3.abf & 4700\\\\\n",
       "\t66 & Inflammatory Bowel Disease & CD4T1MB\\_HLA-DQA2     & 0.8770284 & CD4T1MB     & HLA-DQA2 & PP.H3.abf & 4700\\\\\n",
       "\t71 & Inflammatory Bowel Disease & CD8T1MB\\_HLA-DQA2     & 0.9360076 & CD8T1MB     & HLA-DQA2 & PP.H3.abf & 4700\\\\\n",
       "\t72 & Inflammatory Bowel Disease & CD8T1MB\\_RNASET2      & 0.6274067 & CD8T1MB     & RNASET2  & PP.H3.abf & 2704\\\\\n",
       "\t76 & Inflammatory Bowel Disease & DC1MB\\_HLA-DQA2       & 0.9242179 & DC1MB       & HLA-DQA2 & PP.H3.abf & 4700\\\\\n",
       "\t81 & Inflammatory Bowel Disease & monocyte1MB\\_HLA-DQA2 & 0.9066889 & monocyte1MB & HLA-DQA2 & PP.H3.abf & 4700\\\\\n",
       "\t86 & Inflammatory Bowel Disease & NK1MB\\_HLA-DQA2       & 0.9820401 & NK1MB       & HLA-DQA2 & PP.H3.abf & 4700\\\\\n",
       "\t87 & Inflammatory Bowel Disease & NK1MB\\_RNASET2        & 0.4851461 & NK1MB       & RNASET2  & PP.H3.abf & 2704\\\\\n",
       "\t126 & Rheumatoid Arthritis       & CD4T1MB\\_HLA-DQA2     & 0.6547936 & CD4T1MB     & HLA-DQA2 & PP.H3.abf &  834\\\\\n",
       "\t127 & Rheumatoid Arthritis       & CD4T1MB\\_RNASET2      & 1.0000000 & CD4T1MB     & RNASET2  & PP.H3.abf & 2031\\\\\n",
       "\t131 & Rheumatoid Arthritis       & CD8T1MB\\_HLA-DQA2     & 0.7767070 & CD8T1MB     & HLA-DQA2 & PP.H3.abf &  834\\\\\n",
       "\t132 & Rheumatoid Arthritis       & CD8T1MB\\_RNASET2      & 0.9994734 & CD8T1MB     & RNASET2  & PP.H3.abf & 2031\\\\\n",
       "\t146 & Rheumatoid Arthritis       & NK1MB\\_HLA-DQA2       & 0.6625783 & NK1MB       & HLA-DQA2 & PP.H3.abf &  834\\\\\n",
       "\t147 & Rheumatoid Arthritis       & NK1MB\\_RNASET2        & 0.7544265 & NK1MB       & RNASET2  & PP.H3.abf & 2031\\\\\n",
       "\t151 & Type\\_1\\_Diabetes            & B1MB\\_HLA-DQA2        & 1.0000000 & B1MB        & HLA-DQA2 & PP.H3.abf & 1344\\\\\n",
       "\t153 & Type\\_1\\_Diabetes            & B1MB\\_RPS26           & 0.9998778 & B1MB        & RPS26    & PP.H3.abf & 1341\\\\\n",
       "\t156 & Type\\_1\\_Diabetes            & CD4T1MB\\_HLA-DQA2     & 0.9995561 & CD4T1MB     & HLA-DQA2 & PP.H3.abf & 1344\\\\\n",
       "\t158 & Type\\_1\\_Diabetes            & CD4T1MB\\_RPS26        & 0.9997676 & CD4T1MB     & RPS26    & PP.H3.abf & 1341\\\\\n",
       "\t161 & Type\\_1\\_Diabetes            & CD8T1MB\\_HLA-DQA2     & 1.0000000 & CD8T1MB     & HLA-DQA2 & PP.H3.abf & 1344\\\\\n",
       "\t163 & Type\\_1\\_Diabetes            & CD8T1MB\\_RPS26        & 0.9995874 & CD8T1MB     & RPS26    & PP.H3.abf & 1341\\\\\n",
       "\t166 & Type\\_1\\_Diabetes            & DC1MB\\_HLA-DQA2       & 1.0000000 & DC1MB       & HLA-DQA2 & PP.H3.abf & 1344\\\\\n",
       "\t168 & Type\\_1\\_Diabetes            & DC1MB\\_RPS26          & 0.9995863 & DC1MB       & RPS26    & PP.H3.abf & 1341\\\\\n",
       "\t171 & Type\\_1\\_Diabetes            & monocyte1MB\\_HLA-DQA2 & 1.0000000 & monocyte1MB & HLA-DQA2 & PP.H3.abf & 1344\\\\\n",
       "\t173 & Type\\_1\\_Diabetes            & monocyte1MB\\_RPS26    & 0.9998459 & monocyte1MB & RPS26    & PP.H3.abf & 1341\\\\\n",
       "\t176 & Type\\_1\\_Diabetes            & NK1MB\\_HLA-DQA2       & 0.9999993 & NK1MB       & HLA-DQA2 & PP.H3.abf & 1344\\\\\n",
       "\t178 & Type\\_1\\_Diabetes            & NK1MB\\_RPS26          & 0.9996350 & NK1MB       & RPS26    & PP.H3.abf & 1341\\\\\n",
       "\t181 & White blood cell count     & B1MB\\_HLA-DQA2        & 1.0000000 & B1MB        & HLA-DQA2 & PP.H3.abf &  517\\\\\n",
       "\t186 & White blood cell count     & CD4T1MB\\_HLA-DQA2     & 0.7634488 & CD4T1MB     & HLA-DQA2 & PP.H3.abf &  517\\\\\n",
       "\t191 & White blood cell count     & CD8T1MB\\_HLA-DQA2     & 0.9999464 & CD8T1MB     & HLA-DQA2 & PP.H3.abf &  517\\\\\n",
       "\t196 & White blood cell count     & DC1MB\\_HLA-DQA2       & 1.0000000 & DC1MB       & HLA-DQA2 & PP.H3.abf &  517\\\\\n",
       "\t201 & White blood cell count     & monocyte1MB\\_HLA-DQA2 & 0.9999996 & monocyte1MB & HLA-DQA2 & PP.H3.abf &  517\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 38 × 7\n",
       "\n",
       "| <!--/--> | trait &lt;chr&gt; | identifier &lt;chr&gt; | value &lt;dbl&gt; | cell_type &lt;chr&gt; | gene &lt;chr&gt; | parameter &lt;chr&gt; | overlapping_snps &lt;dbl&gt; |\n",
       "|---|---|---|---|---|---|---|---|\n",
       "| 31 | Crohn's Disease            | B1MB_HLA-DQA2        | 0.9999567 | B1MB        | HLA-DQA2 | PP.H3.abf | 4698 |\n",
       "| 36 | Crohn's Disease            | CD4T1MB_HLA-DQA2     | 0.9998617 | CD4T1MB     | HLA-DQA2 | PP.H3.abf | 4698 |\n",
       "| 41 | Crohn's Disease            | CD8T1MB_HLA-DQA2     | 0.9995537 | CD8T1MB     | HLA-DQA2 | PP.H3.abf | 4698 |\n",
       "| 46 | Crohn's Disease            | DC1MB_HLA-DQA2       | 0.9999567 | DC1MB       | HLA-DQA2 | PP.H3.abf | 4698 |\n",
       "| 51 | Crohn's Disease            | monocyte1MB_HLA-DQA2 | 0.9999567 | monocyte1MB | HLA-DQA2 | PP.H3.abf | 4698 |\n",
       "| 56 | Crohn's Disease            | NK1MB_HLA-DQA2       | 0.9998702 | NK1MB       | HLA-DQA2 | PP.H3.abf | 4698 |\n",
       "| 57 | Crohn's Disease            | NK1MB_RNASET2        | 0.5016812 | NK1MB       | RNASET2  | PP.H3.abf | 2707 |\n",
       "| 61 | Inflammatory Bowel Disease | B1MB_HLA-DQA2        | 0.9263285 | B1MB        | HLA-DQA2 | PP.H3.abf | 4700 |\n",
       "| 66 | Inflammatory Bowel Disease | CD4T1MB_HLA-DQA2     | 0.8770284 | CD4T1MB     | HLA-DQA2 | PP.H3.abf | 4700 |\n",
       "| 71 | Inflammatory Bowel Disease | CD8T1MB_HLA-DQA2     | 0.9360076 | CD8T1MB     | HLA-DQA2 | PP.H3.abf | 4700 |\n",
       "| 72 | Inflammatory Bowel Disease | CD8T1MB_RNASET2      | 0.6274067 | CD8T1MB     | RNASET2  | PP.H3.abf | 2704 |\n",
       "| 76 | Inflammatory Bowel Disease | DC1MB_HLA-DQA2       | 0.9242179 | DC1MB       | HLA-DQA2 | PP.H3.abf | 4700 |\n",
       "| 81 | Inflammatory Bowel Disease | monocyte1MB_HLA-DQA2 | 0.9066889 | monocyte1MB | HLA-DQA2 | PP.H3.abf | 4700 |\n",
       "| 86 | Inflammatory Bowel Disease | NK1MB_HLA-DQA2       | 0.9820401 | NK1MB       | HLA-DQA2 | PP.H3.abf | 4700 |\n",
       "| 87 | Inflammatory Bowel Disease | NK1MB_RNASET2        | 0.4851461 | NK1MB       | RNASET2  | PP.H3.abf | 2704 |\n",
       "| 126 | Rheumatoid Arthritis       | CD4T1MB_HLA-DQA2     | 0.6547936 | CD4T1MB     | HLA-DQA2 | PP.H3.abf |  834 |\n",
       "| 127 | Rheumatoid Arthritis       | CD4T1MB_RNASET2      | 1.0000000 | CD4T1MB     | RNASET2  | PP.H3.abf | 2031 |\n",
       "| 131 | Rheumatoid Arthritis       | CD8T1MB_HLA-DQA2     | 0.7767070 | CD8T1MB     | HLA-DQA2 | PP.H3.abf |  834 |\n",
       "| 132 | Rheumatoid Arthritis       | CD8T1MB_RNASET2      | 0.9994734 | CD8T1MB     | RNASET2  | PP.H3.abf | 2031 |\n",
       "| 146 | Rheumatoid Arthritis       | NK1MB_HLA-DQA2       | 0.6625783 | NK1MB       | HLA-DQA2 | PP.H3.abf |  834 |\n",
       "| 147 | Rheumatoid Arthritis       | NK1MB_RNASET2        | 0.7544265 | NK1MB       | RNASET2  | PP.H3.abf | 2031 |\n",
       "| 151 | Type_1_Diabetes            | B1MB_HLA-DQA2        | 1.0000000 | B1MB        | HLA-DQA2 | PP.H3.abf | 1344 |\n",
       "| 153 | Type_1_Diabetes            | B1MB_RPS26           | 0.9998778 | B1MB        | RPS26    | PP.H3.abf | 1341 |\n",
       "| 156 | Type_1_Diabetes            | CD4T1MB_HLA-DQA2     | 0.9995561 | CD4T1MB     | HLA-DQA2 | PP.H3.abf | 1344 |\n",
       "| 158 | Type_1_Diabetes            | CD4T1MB_RPS26        | 0.9997676 | CD4T1MB     | RPS26    | PP.H3.abf | 1341 |\n",
       "| 161 | Type_1_Diabetes            | CD8T1MB_HLA-DQA2     | 1.0000000 | CD8T1MB     | HLA-DQA2 | PP.H3.abf | 1344 |\n",
       "| 163 | Type_1_Diabetes            | CD8T1MB_RPS26        | 0.9995874 | CD8T1MB     | RPS26    | PP.H3.abf | 1341 |\n",
       "| 166 | Type_1_Diabetes            | DC1MB_HLA-DQA2       | 1.0000000 | DC1MB       | HLA-DQA2 | PP.H3.abf | 1344 |\n",
       "| 168 | Type_1_Diabetes            | DC1MB_RPS26          | 0.9995863 | DC1MB       | RPS26    | PP.H3.abf | 1341 |\n",
       "| 171 | Type_1_Diabetes            | monocyte1MB_HLA-DQA2 | 1.0000000 | monocyte1MB | HLA-DQA2 | PP.H3.abf | 1344 |\n",
       "| 173 | Type_1_Diabetes            | monocyte1MB_RPS26    | 0.9998459 | monocyte1MB | RPS26    | PP.H3.abf | 1341 |\n",
       "| 176 | Type_1_Diabetes            | NK1MB_HLA-DQA2       | 0.9999993 | NK1MB       | HLA-DQA2 | PP.H3.abf | 1344 |\n",
       "| 178 | Type_1_Diabetes            | NK1MB_RPS26          | 0.9996350 | NK1MB       | RPS26    | PP.H3.abf | 1341 |\n",
       "| 181 | White blood cell count     | B1MB_HLA-DQA2        | 1.0000000 | B1MB        | HLA-DQA2 | PP.H3.abf |  517 |\n",
       "| 186 | White blood cell count     | CD4T1MB_HLA-DQA2     | 0.7634488 | CD4T1MB     | HLA-DQA2 | PP.H3.abf |  517 |\n",
       "| 191 | White blood cell count     | CD8T1MB_HLA-DQA2     | 0.9999464 | CD8T1MB     | HLA-DQA2 | PP.H3.abf |  517 |\n",
       "| 196 | White blood cell count     | DC1MB_HLA-DQA2       | 1.0000000 | DC1MB       | HLA-DQA2 | PP.H3.abf |  517 |\n",
       "| 201 | White blood cell count     | monocyte1MB_HLA-DQA2 | 0.9999996 | monocyte1MB | HLA-DQA2 | PP.H3.abf |  517 |\n",
       "\n"
      ],
      "text/plain": [
       "    trait                      identifier           value     cell_type  \n",
       "31  Crohn's Disease            B1MB_HLA-DQA2        0.9999567 B1MB       \n",
       "36  Crohn's Disease            CD4T1MB_HLA-DQA2     0.9998617 CD4T1MB    \n",
       "41  Crohn's Disease            CD8T1MB_HLA-DQA2     0.9995537 CD8T1MB    \n",
       "46  Crohn's Disease            DC1MB_HLA-DQA2       0.9999567 DC1MB      \n",
       "51  Crohn's Disease            monocyte1MB_HLA-DQA2 0.9999567 monocyte1MB\n",
       "56  Crohn's Disease            NK1MB_HLA-DQA2       0.9998702 NK1MB      \n",
       "57  Crohn's Disease            NK1MB_RNASET2        0.5016812 NK1MB      \n",
       "61  Inflammatory Bowel Disease B1MB_HLA-DQA2        0.9263285 B1MB       \n",
       "66  Inflammatory Bowel Disease CD4T1MB_HLA-DQA2     0.8770284 CD4T1MB    \n",
       "71  Inflammatory Bowel Disease CD8T1MB_HLA-DQA2     0.9360076 CD8T1MB    \n",
       "72  Inflammatory Bowel Disease CD8T1MB_RNASET2      0.6274067 CD8T1MB    \n",
       "76  Inflammatory Bowel Disease DC1MB_HLA-DQA2       0.9242179 DC1MB      \n",
       "81  Inflammatory Bowel Disease monocyte1MB_HLA-DQA2 0.9066889 monocyte1MB\n",
       "86  Inflammatory Bowel Disease NK1MB_HLA-DQA2       0.9820401 NK1MB      \n",
       "87  Inflammatory Bowel Disease NK1MB_RNASET2        0.4851461 NK1MB      \n",
       "126 Rheumatoid Arthritis       CD4T1MB_HLA-DQA2     0.6547936 CD4T1MB    \n",
       "127 Rheumatoid Arthritis       CD4T1MB_RNASET2      1.0000000 CD4T1MB    \n",
       "131 Rheumatoid Arthritis       CD8T1MB_HLA-DQA2     0.7767070 CD8T1MB    \n",
       "132 Rheumatoid Arthritis       CD8T1MB_RNASET2      0.9994734 CD8T1MB    \n",
       "146 Rheumatoid Arthritis       NK1MB_HLA-DQA2       0.6625783 NK1MB      \n",
       "147 Rheumatoid Arthritis       NK1MB_RNASET2        0.7544265 NK1MB      \n",
       "151 Type_1_Diabetes            B1MB_HLA-DQA2        1.0000000 B1MB       \n",
       "153 Type_1_Diabetes            B1MB_RPS26           0.9998778 B1MB       \n",
       "156 Type_1_Diabetes            CD4T1MB_HLA-DQA2     0.9995561 CD4T1MB    \n",
       "158 Type_1_Diabetes            CD4T1MB_RPS26        0.9997676 CD4T1MB    \n",
       "161 Type_1_Diabetes            CD8T1MB_HLA-DQA2     1.0000000 CD8T1MB    \n",
       "163 Type_1_Diabetes            CD8T1MB_RPS26        0.9995874 CD8T1MB    \n",
       "166 Type_1_Diabetes            DC1MB_HLA-DQA2       1.0000000 DC1MB      \n",
       "168 Type_1_Diabetes            DC1MB_RPS26          0.9995863 DC1MB      \n",
       "171 Type_1_Diabetes            monocyte1MB_HLA-DQA2 1.0000000 monocyte1MB\n",
       "173 Type_1_Diabetes            monocyte1MB_RPS26    0.9998459 monocyte1MB\n",
       "176 Type_1_Diabetes            NK1MB_HLA-DQA2       0.9999993 NK1MB      \n",
       "178 Type_1_Diabetes            NK1MB_RPS26          0.9996350 NK1MB      \n",
       "181 White blood cell count     B1MB_HLA-DQA2        1.0000000 B1MB       \n",
       "186 White blood cell count     CD4T1MB_HLA-DQA2     0.7634488 CD4T1MB    \n",
       "191 White blood cell count     CD8T1MB_HLA-DQA2     0.9999464 CD8T1MB    \n",
       "196 White blood cell count     DC1MB_HLA-DQA2       1.0000000 DC1MB      \n",
       "201 White blood cell count     monocyte1MB_HLA-DQA2 0.9999996 monocyte1MB\n",
       "    gene     parameter overlapping_snps\n",
       "31  HLA-DQA2 PP.H3.abf 4698            \n",
       "36  HLA-DQA2 PP.H3.abf 4698            \n",
       "41  HLA-DQA2 PP.H3.abf 4698            \n",
       "46  HLA-DQA2 PP.H3.abf 4698            \n",
       "51  HLA-DQA2 PP.H3.abf 4698            \n",
       "56  HLA-DQA2 PP.H3.abf 4698            \n",
       "57  RNASET2  PP.H3.abf 2707            \n",
       "61  HLA-DQA2 PP.H3.abf 4700            \n",
       "66  HLA-DQA2 PP.H3.abf 4700            \n",
       "71  HLA-DQA2 PP.H3.abf 4700            \n",
       "72  RNASET2  PP.H3.abf 2704            \n",
       "76  HLA-DQA2 PP.H3.abf 4700            \n",
       "81  HLA-DQA2 PP.H3.abf 4700            \n",
       "86  HLA-DQA2 PP.H3.abf 4700            \n",
       "87  RNASET2  PP.H3.abf 2704            \n",
       "126 HLA-DQA2 PP.H3.abf  834            \n",
       "127 RNASET2  PP.H3.abf 2031            \n",
       "131 HLA-DQA2 PP.H3.abf  834            \n",
       "132 RNASET2  PP.H3.abf 2031            \n",
       "146 HLA-DQA2 PP.H3.abf  834            \n",
       "147 RNASET2  PP.H3.abf 2031            \n",
       "151 HLA-DQA2 PP.H3.abf 1344            \n",
       "153 RPS26    PP.H3.abf 1341            \n",
       "156 HLA-DQA2 PP.H3.abf 1344            \n",
       "158 RPS26    PP.H3.abf 1341            \n",
       "161 HLA-DQA2 PP.H3.abf 1344            \n",
       "163 RPS26    PP.H3.abf 1341            \n",
       "166 HLA-DQA2 PP.H3.abf 1344            \n",
       "168 RPS26    PP.H3.abf 1341            \n",
       "171 HLA-DQA2 PP.H3.abf 1344            \n",
       "173 RPS26    PP.H3.abf 1341            \n",
       "176 HLA-DQA2 PP.H3.abf 1344            \n",
       "178 RPS26    PP.H3.abf 1341            \n",
       "181 HLA-DQA2 PP.H3.abf  517            \n",
       "186 HLA-DQA2 PP.H3.abf  517            \n",
       "191 HLA-DQA2 PP.H3.abf  517            \n",
       "196 HLA-DQA2 PP.H3.abf  517            \n",
       "201 HLA-DQA2 PP.H3.abf  517            "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "eqtl_summary_filtered[(eqtl_summary_filtered$parameter == parameter_var) ,]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "2583253d-247b-439f-978c-6bdfd8067b16",
   "metadata": {},
   "outputs": [],
   "source": [
    "### Save eqtl summary for supplementary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "50a4382c-24d8-419e-985c-146799b862eb",
   "metadata": {},
   "outputs": [],
   "source": [
    "eqtl_supp = eqtl_summary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "0b4ff2b7-8343-48cf-a977-871cedea631c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 2 × 7</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>trait</th><th scope=col>identifier</th><th scope=col>parameter</th><th scope=col>value</th><th scope=col>cell_type</th><th scope=col>gene</th><th scope=col>overlapping_snps</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>1</th><td>Asthma</td><td>B1MB_HLA-DQA2</td><td>nsnps    </td><td>3.880000e+02</td><td>B1MB</td><td>HLA-DQA2</td><td>388</td></tr>\n",
       "\t<tr><th scope=row>2</th><td>Asthma</td><td>B1MB_HLA-DQA2</td><td>PP.H0.abf</td><td>1.212062e-25</td><td>B1MB</td><td>HLA-DQA2</td><td>388</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 2 × 7\n",
       "\\begin{tabular}{r|lllllll}\n",
       "  & trait & identifier & parameter & value & cell\\_type & gene & overlapping\\_snps\\\\\n",
       "  & <chr> & <chr> & <chr> & <dbl> & <chr> & <chr> & <dbl>\\\\\n",
       "\\hline\n",
       "\t1 & Asthma & B1MB\\_HLA-DQA2 & nsnps     & 3.880000e+02 & B1MB & HLA-DQA2 & 388\\\\\n",
       "\t2 & Asthma & B1MB\\_HLA-DQA2 & PP.H0.abf & 1.212062e-25 & B1MB & HLA-DQA2 & 388\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 2 × 7\n",
       "\n",
       "| <!--/--> | trait &lt;chr&gt; | identifier &lt;chr&gt; | parameter &lt;chr&gt; | value &lt;dbl&gt; | cell_type &lt;chr&gt; | gene &lt;chr&gt; | overlapping_snps &lt;dbl&gt; |\n",
       "|---|---|---|---|---|---|---|---|\n",
       "| 1 | Asthma | B1MB_HLA-DQA2 | nsnps     | 3.880000e+02 | B1MB | HLA-DQA2 | 388 |\n",
       "| 2 | Asthma | B1MB_HLA-DQA2 | PP.H0.abf | 1.212062e-25 | B1MB | HLA-DQA2 | 388 |\n",
       "\n"
      ],
      "text/plain": [
       "  trait  identifier    parameter value        cell_type gene    \n",
       "1 Asthma B1MB_HLA-DQA2 nsnps     3.880000e+02 B1MB      HLA-DQA2\n",
       "2 Asthma B1MB_HLA-DQA2 PP.H0.abf 1.212062e-25 B1MB      HLA-DQA2\n",
       "  overlapping_snps\n",
       "1 388             \n",
       "2 388             "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "head(eqtl_supp,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "533f9da1-2a30-4b9a-a067-aafa9bd4e634",
   "metadata": {},
   "outputs": [],
   "source": [
    "eqtl_supp = eqtl_supp[(eqtl_supp$parameter %in% c('PP.H3.abf','PP.H4.abf' )) ,]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "124508a4-1019-407b-9dc8-f66cb4abaf92",
   "metadata": {},
   "outputs": [],
   "source": [
    "eqtl_supp$identifier = NULL"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "bdd4eeaf-fbf4-4d16-8828-025858231946",
   "metadata": {},
   "outputs": [],
   "source": [
    "eqtl_supp$egene = eqtl_supp$gene\n",
    "eqtl_supp$gene = NULL"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "eb687509-1146-44a3-be0b-795ada02ef07",
   "metadata": {},
   "outputs": [],
   "source": [
    "eqtl_supp$coloc_hypothesis = eqtl_supp$parameter\n",
    "eqtl_supp$parameter = NULL"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "a68b4cb1-ef86-45e0-9f62-9718162a2cfe",
   "metadata": {},
   "outputs": [],
   "source": [
    "eqtl_supp$cell_type = str_replace(eqtl_supp$cell_type, '1MB', '')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "76b55b08-401d-4871-b45d-8bb75859e7da",
   "metadata": {},
   "outputs": [],
   "source": [
    "eqtl_supp$pp_value = eqtl_supp$value\n",
    "eqtl_supp$value = NULL"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "08ee4113-b4e3-41b8-8ec4-93e353f1c5bb",
   "metadata": {},
   "outputs": [],
   "source": [
    "eqtl_supp$amount_overlapping_snps = eqtl_supp$overlapping_snps \n",
    "eqtl_supp$overlapping_snps = NULL"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "fb8814c1-663a-4b8f-bd46-9d81eab02035",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 3 × 6</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>trait</th><th scope=col>cell_type</th><th scope=col>egene</th><th scope=col>coloc_hypothesis</th><th scope=col>pp_value</th><th scope=col>amount_overlapping_snps</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>5</th><td>Asthma</td><td>B</td><td>HLA-DQA2</td><td>PP.H3.abf</td><td>0.0002647404</td><td> 388</td></tr>\n",
       "\t<tr><th scope=row>6</th><td>Asthma</td><td>B</td><td>HLA-DQA2</td><td>PP.H4.abf</td><td>0.9997352596</td><td> 388</td></tr>\n",
       "\t<tr><th scope=row>11</th><td>Asthma</td><td>B</td><td>RNASET2 </td><td>PP.H3.abf</td><td>0.0018053181</td><td>1133</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 3 × 6\n",
       "\\begin{tabular}{r|llllll}\n",
       "  & trait & cell\\_type & egene & coloc\\_hypothesis & pp\\_value & amount\\_overlapping\\_snps\\\\\n",
       "  & <chr> & <chr> & <chr> & <chr> & <dbl> & <dbl>\\\\\n",
       "\\hline\n",
       "\t5 & Asthma & B & HLA-DQA2 & PP.H3.abf & 0.0002647404 &  388\\\\\n",
       "\t6 & Asthma & B & HLA-DQA2 & PP.H4.abf & 0.9997352596 &  388\\\\\n",
       "\t11 & Asthma & B & RNASET2  & PP.H3.abf & 0.0018053181 & 1133\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 3 × 6\n",
       "\n",
       "| <!--/--> | trait &lt;chr&gt; | cell_type &lt;chr&gt; | egene &lt;chr&gt; | coloc_hypothesis &lt;chr&gt; | pp_value &lt;dbl&gt; | amount_overlapping_snps &lt;dbl&gt; |\n",
       "|---|---|---|---|---|---|---|\n",
       "| 5 | Asthma | B | HLA-DQA2 | PP.H3.abf | 0.0002647404 |  388 |\n",
       "| 6 | Asthma | B | HLA-DQA2 | PP.H4.abf | 0.9997352596 |  388 |\n",
       "| 11 | Asthma | B | RNASET2  | PP.H3.abf | 0.0018053181 | 1133 |\n",
       "\n"
      ],
      "text/plain": [
       "   trait  cell_type egene    coloc_hypothesis pp_value    \n",
       "5  Asthma B         HLA-DQA2 PP.H3.abf        0.0002647404\n",
       "6  Asthma B         HLA-DQA2 PP.H4.abf        0.9997352596\n",
       "11 Asthma B         RNASET2  PP.H3.abf        0.0018053181\n",
       "   amount_overlapping_snps\n",
       "5   388                   \n",
       "6   388                   \n",
       "11 1133                   "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "head(eqtl_supp,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8fdbde2f-a449-4270-be11-8a4f9857a123",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "e67d6835-f0e1-4696-b12f-b0eb7de6b573",
   "metadata": {},
   "outputs": [],
   "source": [
    "write.table(eqtl_supp, file = paste0(path, \"/colocalization_results/\", \"Coloc_EQTL_supp_table.csv\"), append =FALSE, sep = \",\", row.names = FALSE, col.names =TRUE)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b8b5a092-17bc-4e53-b279-4fdf271ee30c",
   "metadata": {
    "tags": []
   },
   "source": [
    "## For Co-EQTLs"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3bff68b2-5251-4f43-88ef-8dad37dcd0f5",
   "metadata": {},
   "source": [
    "### General summaries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "14c7f569-6d8d-4286-a74a-4e9b8a2dd6c1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 2 × 5</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>parameter</th><th scope=col>value</th><th scope=col>trait</th><th scope=col>identifier</th><th scope=col>egene</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>1</th><td>nsnps    </td><td>2.461000e+03</td><td>White blood cell count</td><td>monocyte_TMEM176A___CAPG__TMEM176A</td><td>monocyte_TMEM176A</td></tr>\n",
       "\t<tr><th scope=row>2</th><td>PP.H0.abf</td><td>2.606173e-02</td><td>White blood cell count</td><td>monocyte_TMEM176A___CAPG__TMEM176A</td><td>monocyte_TMEM176A</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 2 × 5\n",
       "\\begin{tabular}{r|lllll}\n",
       "  & parameter & value & trait & identifier & egene\\\\\n",
       "  & <chr> & <dbl> & <chr> & <chr> & <chr>\\\\\n",
       "\\hline\n",
       "\t1 & nsnps     & 2.461000e+03 & White blood cell count & monocyte\\_TMEM176A\\_\\_\\_CAPG\\_\\_TMEM176A & monocyte\\_TMEM176A\\\\\n",
       "\t2 & PP.H0.abf & 2.606173e-02 & White blood cell count & monocyte\\_TMEM176A\\_\\_\\_CAPG\\_\\_TMEM176A & monocyte\\_TMEM176A\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 2 × 5\n",
       "\n",
       "| <!--/--> | parameter &lt;chr&gt; | value &lt;dbl&gt; | trait &lt;chr&gt; | identifier &lt;chr&gt; | egene &lt;chr&gt; |\n",
       "|---|---|---|---|---|---|\n",
       "| 1 | nsnps     | 2.461000e+03 | White blood cell count | monocyte_TMEM176A___CAPG__TMEM176A | monocyte_TMEM176A |\n",
       "| 2 | PP.H0.abf | 2.606173e-02 | White blood cell count | monocyte_TMEM176A___CAPG__TMEM176A | monocyte_TMEM176A |\n",
       "\n"
      ],
      "text/plain": [
       "  parameter value        trait                 \n",
       "1 nsnps     2.461000e+03 White blood cell count\n",
       "2 PP.H0.abf 2.606173e-02 White blood cell count\n",
       "  identifier                         egene            \n",
       "1 monocyte_TMEM176A___CAPG__TMEM176A monocyte_TMEM176A\n",
       "2 monocyte_TMEM176A___CAPG__TMEM176A monocyte_TMEM176A"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "head(coeqtl_summary,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "e3201d61-d405-45c2-ae35-97452c21af24",
   "metadata": {},
   "outputs": [],
   "source": [
    "## extract amount of SNPs info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "06bb4100-9486-4566-9d1e-b622f04b53f3",
   "metadata": {},
   "outputs": [],
   "source": [
    "n_snps = coeqtl_summary[coeqtl_summary$parameter == 'nsnps',]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "4a5940e1-a100-4e9f-a90e-a95bddf3d371",
   "metadata": {},
   "outputs": [],
   "source": [
    "n_snps$overlapping_snps = n_snps$value\n",
    "n_snps$parameter = NULL\n",
    "n_snps$value = NULL"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "2e06514d-3f8c-45ab-8ebe-cba6301ba0e9",
   "metadata": {},
   "outputs": [],
   "source": [
    "## Extract relevant columsn"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "c7f7ddde-d16b-42b5-a9b2-b8dd5fd9a615",
   "metadata": {},
   "outputs": [],
   "source": [
    "coeqtl_summary = coeqtl_summary[coeqtl_summary$parameter != 'nsnps',]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "13dbdd66-9c1b-483e-9307-b5fc88370e57",
   "metadata": {},
   "outputs": [],
   "source": [
    "coeqtl_summary$cell_type = str_replace(coeqtl_summary$identifier, '_.*', '')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "9baece63-8981-49e2-b3f0-e94e15165618",
   "metadata": {},
   "outputs": [],
   "source": [
    "#tail(coeqtl_summary,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "cee1a263-8956-421f-ad12-6be2337287d3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>\n",
       ".list-inline {list-style: none; margin:0; padding: 0}\n",
       ".list-inline>li {display: inline-block}\n",
       ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
       "</style>\n",
       "<ol class=list-inline><li>'monocyte'</li><li>'CD8T'</li><li>'CD4T'</li><li>'DC'</li><li>'B'</li><li>'NK'</li></ol>\n"
      ],
      "text/latex": [
       "\\begin{enumerate*}\n",
       "\\item 'monocyte'\n",
       "\\item 'CD8T'\n",
       "\\item 'CD4T'\n",
       "\\item 'DC'\n",
       "\\item 'B'\n",
       "\\item 'NK'\n",
       "\\end{enumerate*}\n"
      ],
      "text/markdown": [
       "1. 'monocyte'\n",
       "2. 'CD8T'\n",
       "3. 'CD4T'\n",
       "4. 'DC'\n",
       "5. 'B'\n",
       "6. 'NK'\n",
       "\n",
       "\n"
      ],
      "text/plain": [
       "[1] \"monocyte\" \"CD8T\"     \"CD4T\"     \"DC\"       \"B\"        \"NK\"      "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "unique(coeqtl_summary$cell_type)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "e368cc1e-8bbd-49d2-9bb9-c67c52744dc4",
   "metadata": {},
   "outputs": [],
   "source": [
    "coeqtl_summary$gene = str_extract(coeqtl_summary$identifier, '_.*')\n",
    "coeqtl_summary$gene = str_replace(coeqtl_summary$gene, '.*___', '')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "0953053b-c925-494d-b0e6-de02fa3335f1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "604"
      ],
      "text/latex": [
       "604"
      ],
      "text/markdown": [
       "604"
      ],
      "text/plain": [
       "[1] 604"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "length(unique(coeqtl_summary$gene))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "c0cfee92-8655-4048-92ec-b416594996a9",
   "metadata": {},
   "outputs": [],
   "source": [
    "### Add number of snps"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "34f0729b-889f-4901-9d7f-e94d4788877f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 2 × 4</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>trait</th><th scope=col>identifier</th><th scope=col>egene</th><th scope=col>overlapping_snps</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>1</th><td>White blood cell count</td><td>monocyte_TMEM176A___CAPG__TMEM176A </td><td>monocyte_TMEM176A</td><td>2461</td></tr>\n",
       "\t<tr><th scope=row>7</th><td>White blood cell count</td><td>monocyte_TMEM176A___PTAFR__TMEM176A</td><td>monocyte_TMEM176A</td><td>2461</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 2 × 4\n",
       "\\begin{tabular}{r|llll}\n",
       "  & trait & identifier & egene & overlapping\\_snps\\\\\n",
       "  & <chr> & <chr> & <chr> & <dbl>\\\\\n",
       "\\hline\n",
       "\t1 & White blood cell count & monocyte\\_TMEM176A\\_\\_\\_CAPG\\_\\_TMEM176A  & monocyte\\_TMEM176A & 2461\\\\\n",
       "\t7 & White blood cell count & monocyte\\_TMEM176A\\_\\_\\_PTAFR\\_\\_TMEM176A & monocyte\\_TMEM176A & 2461\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 2 × 4\n",
       "\n",
       "| <!--/--> | trait &lt;chr&gt; | identifier &lt;chr&gt; | egene &lt;chr&gt; | overlapping_snps &lt;dbl&gt; |\n",
       "|---|---|---|---|---|\n",
       "| 1 | White blood cell count | monocyte_TMEM176A___CAPG__TMEM176A  | monocyte_TMEM176A | 2461 |\n",
       "| 7 | White blood cell count | monocyte_TMEM176A___PTAFR__TMEM176A | monocyte_TMEM176A | 2461 |\n",
       "\n"
      ],
      "text/plain": [
       "  trait                  identifier                          egene            \n",
       "1 White blood cell count monocyte_TMEM176A___CAPG__TMEM176A  monocyte_TMEM176A\n",
       "7 White blood cell count monocyte_TMEM176A___PTAFR__TMEM176A monocyte_TMEM176A\n",
       "  overlapping_snps\n",
       "1 2461            \n",
       "7 2461            "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "head(n_snps,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "e692030d-cd63-4a82-9165-b3e3ffc90c44",
   "metadata": {},
   "outputs": [],
   "source": [
    "coeqtl_summary = merge(coeqtl_summary, n_snps, by.x = c('trait', 'identifier', 'egene'), by.y = c('trait', 'identifier', 'egene'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "id": "9eb0ffa6-70a6-45f9-96a3-ee526c66a888",
   "metadata": {},
   "outputs": [],
   "source": [
    "### Check out maximum probabilities"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "id": "52fe9faa-5c7b-4ebc-8917-c7f256ca1d6e",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\u001b[1m\u001b[22m`summarise()` has grouped output by 'trait', 'identifier', 'cell_type', 'gene',\n",
      "'overlapping_snps'. You can override using the `.groups` argument.\n"
     ]
    }
   ],
   "source": [
    "max_value = coeqtl_summary %>% group_by(trait, identifier, cell_type, gene, overlapping_snps, egene) %>% summarise(value = max(value))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "id": "98b9eb7f-7dce-4c8d-86bb-5939ba75a195",
   "metadata": {},
   "outputs": [],
   "source": [
    "coeqtl_summary_filtered = merge(coeqtl_summary, max_value)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "id": "d465a856-bf99-46eb-b6d1-105e08447328",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 2 × 8</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>trait</th><th scope=col>identifier</th><th scope=col>egene</th><th scope=col>value</th><th scope=col>cell_type</th><th scope=col>gene</th><th scope=col>overlapping_snps</th><th scope=col>parameter</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;chr&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>1</th><td>Asthma</td><td>B_RPS26___EEF1A1__RPS26</td><td>B_RPS26</td><td>0.3734713</td><td>B</td><td>EEF1A1__RPS26</td><td>381</td><td>PP.H0.abf</td></tr>\n",
       "\t<tr><th scope=row>2</th><td>Asthma</td><td>B_RPS26___RPL10__RPS26 </td><td>B_RPS26</td><td>0.6338403</td><td>B</td><td>RPL10__RPS26 </td><td>381</td><td>PP.H4.abf</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 2 × 8\n",
       "\\begin{tabular}{r|llllllll}\n",
       "  & trait & identifier & egene & value & cell\\_type & gene & overlapping\\_snps & parameter\\\\\n",
       "  & <chr> & <chr> & <chr> & <dbl> & <chr> & <chr> & <dbl> & <chr>\\\\\n",
       "\\hline\n",
       "\t1 & Asthma & B\\_RPS26\\_\\_\\_EEF1A1\\_\\_RPS26 & B\\_RPS26 & 0.3734713 & B & EEF1A1\\_\\_RPS26 & 381 & PP.H0.abf\\\\\n",
       "\t2 & Asthma & B\\_RPS26\\_\\_\\_RPL10\\_\\_RPS26  & B\\_RPS26 & 0.6338403 & B & RPL10\\_\\_RPS26  & 381 & PP.H4.abf\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 2 × 8\n",
       "\n",
       "| <!--/--> | trait &lt;chr&gt; | identifier &lt;chr&gt; | egene &lt;chr&gt; | value &lt;dbl&gt; | cell_type &lt;chr&gt; | gene &lt;chr&gt; | overlapping_snps &lt;dbl&gt; | parameter &lt;chr&gt; |\n",
       "|---|---|---|---|---|---|---|---|---|\n",
       "| 1 | Asthma | B_RPS26___EEF1A1__RPS26 | B_RPS26 | 0.3734713 | B | EEF1A1__RPS26 | 381 | PP.H0.abf |\n",
       "| 2 | Asthma | B_RPS26___RPL10__RPS26  | B_RPS26 | 0.6338403 | B | RPL10__RPS26  | 381 | PP.H4.abf |\n",
       "\n"
      ],
      "text/plain": [
       "  trait  identifier              egene   value     cell_type gene         \n",
       "1 Asthma B_RPS26___EEF1A1__RPS26 B_RPS26 0.3734713 B         EEF1A1__RPS26\n",
       "2 Asthma B_RPS26___RPL10__RPS26  B_RPS26 0.6338403 B         RPL10__RPS26 \n",
       "  overlapping_snps parameter\n",
       "1 381              PP.H0.abf\n",
       "2 381              PP.H4.abf"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "head(coeqtl_summary_filtered,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "c2c75a27-e6cd-453d-a301-94440f25406d",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\u001b[1m\u001b[22m`summarise()` has grouped output by 'parameter', 'trait'. You can override\n",
      "using the `.groups` argument.\n"
     ]
    }
   ],
   "source": [
    "overview_h_amounts = coeqtl_summary_filtered %>% group_by(parameter, trait, egene ) %>% summarise(n = n(), mean_value = mean(value), amount_greater_0.9 = sum(value > 0.9),  amount_greater_0.75 = sum(value > 0.75),amount_greater_0.5 = sum(value > 0.5),  max_overlap_snps = max(overlapping_snps), min_overlap_snps = min(overlapping_snps), mean_overlap_snps = mean(overlapping_snps))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "id": "fd026fa0-f255-41a3-aa9a-7d028d97c351",
   "metadata": {},
   "outputs": [],
   "source": [
    "overview_h_amounts = overview_h_amounts[order(overview_h_amounts$trait),]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "id": "54f14012-d8b9-4463-b114-96e3231963cc",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\u001b[1m\u001b[22m`summarise()` has grouped output by 'egene'. You can override using the\n",
      "`.groups` argument.\n"
     ]
    }
   ],
   "source": [
    "amount_coegenes_per_e_gene = overview_h_amounts %>% group_by(egene, trait) %>% summarise(total_n = sum(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "id": "8d0b44db-5ef6-4821-be87-ca2740bf2803",
   "metadata": {},
   "outputs": [],
   "source": [
    "overview_h_amounts = merge(overview_h_amounts, amount_coegenes_per_e_gene)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "id": "1cfdbc1e-9270-4158-a9f3-fac044fdfbe9",
   "metadata": {},
   "outputs": [],
   "source": [
    "#### Inspect the results for eGenes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "id": "53698756-d176-4716-a5bb-5c46cda6e69e",
   "metadata": {},
   "outputs": [],
   "source": [
    "### All RPS26 - co-egene examples"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "id": "d6bca892-26b6-40fe-8da0-164cf7437ce7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 15 × 12</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>trait</th><th scope=col>egene</th><th scope=col>parameter</th><th scope=col>n</th><th scope=col>mean_value</th><th scope=col>amount_greater_0.9</th><th scope=col>amount_greater_0.75</th><th scope=col>amount_greater_0.5</th><th scope=col>max_overlap_snps</th><th scope=col>min_overlap_snps</th><th scope=col>mean_overlap_snps</th><th scope=col>total_n</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;int&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>2</th><td>Asthma              </td><td>B_RPS26       </td><td>PP.H4.abf</td><td> 20</td><td>0.5448488</td><td> 0</td><td>  0</td><td> 16</td><td> 381</td><td> 381</td><td> 381.0000</td><td> 35</td></tr>\n",
       "\t<tr><th scope=row>8</th><td>Asthma              </td><td>CD4T_RPS26    </td><td>PP.H4.abf</td><td>353</td><td>0.6166249</td><td> 0</td><td> 28</td><td>323</td><td> 381</td><td> 368</td><td> 380.7734</td><td>372</td></tr>\n",
       "\t<tr><th scope=row>14</th><td>Asthma              </td><td>CD8T_RPS26    </td><td>PP.H4.abf</td><td>241</td><td>0.6293361</td><td> 0</td><td> 31</td><td>212</td><td> 381</td><td> 367</td><td> 380.6307</td><td>293</td></tr>\n",
       "\t<tr><th scope=row>24</th><td>Asthma              </td><td>monocyte_RPS26</td><td>PP.H4.abf</td><td>127</td><td>0.6724475</td><td> 0</td><td> 40</td><td>114</td><td> 381</td><td> 379</td><td> 380.9685</td><td>132</td></tr>\n",
       "\t<tr><th scope=row>28</th><td>Asthma              </td><td>NK_RPS26      </td><td>PP.H4.abf</td><td> 84</td><td>0.6149269</td><td> 0</td><td>  7</td><td> 78</td><td> 379</td><td> 379</td><td> 379.0000</td><td> 96</td></tr>\n",
       "\t<tr><th scope=row>105</th><td>Rheumatoid Arthritis</td><td>B_RPS26       </td><td>PP.H4.abf</td><td> 33</td><td>0.7385906</td><td> 4</td><td> 19</td><td> 31</td><td> 878</td><td> 876</td><td> 877.9394</td><td> 35</td></tr>\n",
       "\t<tr><th scope=row>111</th><td>Rheumatoid Arthritis</td><td>CD4T_RPS26    </td><td>PP.H4.abf</td><td>370</td><td>0.8044940</td><td>41</td><td>325</td><td>368</td><td> 882</td><td> 835</td><td> 881.1541</td><td>372</td></tr>\n",
       "\t<tr><th scope=row>118</th><td>Rheumatoid Arthritis</td><td>CD8T_RPS26    </td><td>PP.H4.abf</td><td>289</td><td>0.8303538</td><td>64</td><td>247</td><td>286</td><td> 882</td><td> 831</td><td> 880.4567</td><td>293</td></tr>\n",
       "\t<tr><th scope=row>123</th><td>Rheumatoid Arthritis</td><td>DC_RPS26      </td><td>PP.H4.abf</td><td>  3</td><td>0.6804751</td><td> 0</td><td>  0</td><td>  3</td><td> 855</td><td> 855</td><td> 855.0000</td><td>  3</td></tr>\n",
       "\t<tr><th scope=row>127</th><td>Rheumatoid Arthritis</td><td>monocyte_RPS26</td><td>PP.H4.abf</td><td>132</td><td>0.7954287</td><td>15</td><td> 98</td><td>132</td><td> 882</td><td> 879</td><td> 881.9545</td><td>132</td></tr>\n",
       "\t<tr><th scope=row>131</th><td>Rheumatoid Arthritis</td><td>NK_RPS26      </td><td>PP.H4.abf</td><td> 94</td><td>0.8435984</td><td>28</td><td> 88</td><td> 94</td><td> 879</td><td> 879</td><td> 879.0000</td><td> 96</td></tr>\n",
       "\t<tr><th scope=row>134</th><td>Type_1_Diabetes     </td><td>B_RPS26       </td><td>PP.H4.abf</td><td>  4</td><td>0.5270015</td><td> 0</td><td>  0</td><td>  2</td><td>1335</td><td>1332</td><td>1334.2500</td><td> 35</td></tr>\n",
       "\t<tr><th scope=row>138</th><td>Type_1_Diabetes     </td><td>CD4T_RPS26    </td><td>PP.H4.abf</td><td> 34</td><td>0.6080222</td><td> 0</td><td>  6</td><td> 28</td><td>1341</td><td>1273</td><td>1337.0882</td><td>372</td></tr>\n",
       "\t<tr><th scope=row>143</th><td>Type_1_Diabetes     </td><td>CD8T_RPS26    </td><td>PP.H4.abf</td><td>  2</td><td>0.5419573</td><td> 0</td><td>  0</td><td>  2</td><td>1341</td><td>1341</td><td>1341.0000</td><td>293</td></tr>\n",
       "\t<tr><th scope=row>155</th><td>Type_1_Diabetes     </td><td>monocyte_RPS26</td><td>PP.H4.abf</td><td>  9</td><td>0.6295441</td><td> 0</td><td>  2</td><td>  9</td><td>1341</td><td>1334</td><td>1340.2222</td><td>132</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 15 × 12\n",
       "\\begin{tabular}{r|llllllllllll}\n",
       "  & trait & egene & parameter & n & mean\\_value & amount\\_greater\\_0.9 & amount\\_greater\\_0.75 & amount\\_greater\\_0.5 & max\\_overlap\\_snps & min\\_overlap\\_snps & mean\\_overlap\\_snps & total\\_n\\\\\n",
       "  & <chr> & <chr> & <chr> & <int> & <dbl> & <int> & <int> & <int> & <dbl> & <dbl> & <dbl> & <int>\\\\\n",
       "\\hline\n",
       "\t2 & Asthma               & B\\_RPS26        & PP.H4.abf &  20 & 0.5448488 &  0 &   0 &  16 &  381 &  381 &  381.0000 &  35\\\\\n",
       "\t8 & Asthma               & CD4T\\_RPS26     & PP.H4.abf & 353 & 0.6166249 &  0 &  28 & 323 &  381 &  368 &  380.7734 & 372\\\\\n",
       "\t14 & Asthma               & CD8T\\_RPS26     & PP.H4.abf & 241 & 0.6293361 &  0 &  31 & 212 &  381 &  367 &  380.6307 & 293\\\\\n",
       "\t24 & Asthma               & monocyte\\_RPS26 & PP.H4.abf & 127 & 0.6724475 &  0 &  40 & 114 &  381 &  379 &  380.9685 & 132\\\\\n",
       "\t28 & Asthma               & NK\\_RPS26       & PP.H4.abf &  84 & 0.6149269 &  0 &   7 &  78 &  379 &  379 &  379.0000 &  96\\\\\n",
       "\t105 & Rheumatoid Arthritis & B\\_RPS26        & PP.H4.abf &  33 & 0.7385906 &  4 &  19 &  31 &  878 &  876 &  877.9394 &  35\\\\\n",
       "\t111 & Rheumatoid Arthritis & CD4T\\_RPS26     & PP.H4.abf & 370 & 0.8044940 & 41 & 325 & 368 &  882 &  835 &  881.1541 & 372\\\\\n",
       "\t118 & Rheumatoid Arthritis & CD8T\\_RPS26     & PP.H4.abf & 289 & 0.8303538 & 64 & 247 & 286 &  882 &  831 &  880.4567 & 293\\\\\n",
       "\t123 & Rheumatoid Arthritis & DC\\_RPS26       & PP.H4.abf &   3 & 0.6804751 &  0 &   0 &   3 &  855 &  855 &  855.0000 &   3\\\\\n",
       "\t127 & Rheumatoid Arthritis & monocyte\\_RPS26 & PP.H4.abf & 132 & 0.7954287 & 15 &  98 & 132 &  882 &  879 &  881.9545 & 132\\\\\n",
       "\t131 & Rheumatoid Arthritis & NK\\_RPS26       & PP.H4.abf &  94 & 0.8435984 & 28 &  88 &  94 &  879 &  879 &  879.0000 &  96\\\\\n",
       "\t134 & Type\\_1\\_Diabetes      & B\\_RPS26        & PP.H4.abf &   4 & 0.5270015 &  0 &   0 &   2 & 1335 & 1332 & 1334.2500 &  35\\\\\n",
       "\t138 & Type\\_1\\_Diabetes      & CD4T\\_RPS26     & PP.H4.abf &  34 & 0.6080222 &  0 &   6 &  28 & 1341 & 1273 & 1337.0882 & 372\\\\\n",
       "\t143 & Type\\_1\\_Diabetes      & CD8T\\_RPS26     & PP.H4.abf &   2 & 0.5419573 &  0 &   0 &   2 & 1341 & 1341 & 1341.0000 & 293\\\\\n",
       "\t155 & Type\\_1\\_Diabetes      & monocyte\\_RPS26 & PP.H4.abf &   9 & 0.6295441 &  0 &   2 &   9 & 1341 & 1334 & 1340.2222 & 132\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 15 × 12\n",
       "\n",
       "| <!--/--> | trait &lt;chr&gt; | egene &lt;chr&gt; | parameter &lt;chr&gt; | n &lt;int&gt; | mean_value &lt;dbl&gt; | amount_greater_0.9 &lt;int&gt; | amount_greater_0.75 &lt;int&gt; | amount_greater_0.5 &lt;int&gt; | max_overlap_snps &lt;dbl&gt; | min_overlap_snps &lt;dbl&gt; | mean_overlap_snps &lt;dbl&gt; | total_n &lt;int&gt; |\n",
       "|---|---|---|---|---|---|---|---|---|---|---|---|---|\n",
       "| 2 | Asthma               | B_RPS26        | PP.H4.abf |  20 | 0.5448488 |  0 |   0 |  16 |  381 |  381 |  381.0000 |  35 |\n",
       "| 8 | Asthma               | CD4T_RPS26     | PP.H4.abf | 353 | 0.6166249 |  0 |  28 | 323 |  381 |  368 |  380.7734 | 372 |\n",
       "| 14 | Asthma               | CD8T_RPS26     | PP.H4.abf | 241 | 0.6293361 |  0 |  31 | 212 |  381 |  367 |  380.6307 | 293 |\n",
       "| 24 | Asthma               | monocyte_RPS26 | PP.H4.abf | 127 | 0.6724475 |  0 |  40 | 114 |  381 |  379 |  380.9685 | 132 |\n",
       "| 28 | Asthma               | NK_RPS26       | PP.H4.abf |  84 | 0.6149269 |  0 |   7 |  78 |  379 |  379 |  379.0000 |  96 |\n",
       "| 105 | Rheumatoid Arthritis | B_RPS26        | PP.H4.abf |  33 | 0.7385906 |  4 |  19 |  31 |  878 |  876 |  877.9394 |  35 |\n",
       "| 111 | Rheumatoid Arthritis | CD4T_RPS26     | PP.H4.abf | 370 | 0.8044940 | 41 | 325 | 368 |  882 |  835 |  881.1541 | 372 |\n",
       "| 118 | Rheumatoid Arthritis | CD8T_RPS26     | PP.H4.abf | 289 | 0.8303538 | 64 | 247 | 286 |  882 |  831 |  880.4567 | 293 |\n",
       "| 123 | Rheumatoid Arthritis | DC_RPS26       | PP.H4.abf |   3 | 0.6804751 |  0 |   0 |   3 |  855 |  855 |  855.0000 |   3 |\n",
       "| 127 | Rheumatoid Arthritis | monocyte_RPS26 | PP.H4.abf | 132 | 0.7954287 | 15 |  98 | 132 |  882 |  879 |  881.9545 | 132 |\n",
       "| 131 | Rheumatoid Arthritis | NK_RPS26       | PP.H4.abf |  94 | 0.8435984 | 28 |  88 |  94 |  879 |  879 |  879.0000 |  96 |\n",
       "| 134 | Type_1_Diabetes      | B_RPS26        | PP.H4.abf |   4 | 0.5270015 |  0 |   0 |   2 | 1335 | 1332 | 1334.2500 |  35 |\n",
       "| 138 | Type_1_Diabetes      | CD4T_RPS26     | PP.H4.abf |  34 | 0.6080222 |  0 |   6 |  28 | 1341 | 1273 | 1337.0882 | 372 |\n",
       "| 143 | Type_1_Diabetes      | CD8T_RPS26     | PP.H4.abf |   2 | 0.5419573 |  0 |   0 |   2 | 1341 | 1341 | 1341.0000 | 293 |\n",
       "| 155 | Type_1_Diabetes      | monocyte_RPS26 | PP.H4.abf |   9 | 0.6295441 |  0 |   2 |   9 | 1341 | 1334 | 1340.2222 | 132 |\n",
       "\n"
      ],
      "text/plain": [
       "    trait                egene          parameter n   mean_value\n",
       "2   Asthma               B_RPS26        PP.H4.abf  20 0.5448488 \n",
       "8   Asthma               CD4T_RPS26     PP.H4.abf 353 0.6166249 \n",
       "14  Asthma               CD8T_RPS26     PP.H4.abf 241 0.6293361 \n",
       "24  Asthma               monocyte_RPS26 PP.H4.abf 127 0.6724475 \n",
       "28  Asthma               NK_RPS26       PP.H4.abf  84 0.6149269 \n",
       "105 Rheumatoid Arthritis B_RPS26        PP.H4.abf  33 0.7385906 \n",
       "111 Rheumatoid Arthritis CD4T_RPS26     PP.H4.abf 370 0.8044940 \n",
       "118 Rheumatoid Arthritis CD8T_RPS26     PP.H4.abf 289 0.8303538 \n",
       "123 Rheumatoid Arthritis DC_RPS26       PP.H4.abf   3 0.6804751 \n",
       "127 Rheumatoid Arthritis monocyte_RPS26 PP.H4.abf 132 0.7954287 \n",
       "131 Rheumatoid Arthritis NK_RPS26       PP.H4.abf  94 0.8435984 \n",
       "134 Type_1_Diabetes      B_RPS26        PP.H4.abf   4 0.5270015 \n",
       "138 Type_1_Diabetes      CD4T_RPS26     PP.H4.abf  34 0.6080222 \n",
       "143 Type_1_Diabetes      CD8T_RPS26     PP.H4.abf   2 0.5419573 \n",
       "155 Type_1_Diabetes      monocyte_RPS26 PP.H4.abf   9 0.6295441 \n",
       "    amount_greater_0.9 amount_greater_0.75 amount_greater_0.5 max_overlap_snps\n",
       "2    0                   0                  16                 381            \n",
       "8    0                  28                 323                 381            \n",
       "14   0                  31                 212                 381            \n",
       "24   0                  40                 114                 381            \n",
       "28   0                   7                  78                 379            \n",
       "105  4                  19                  31                 878            \n",
       "111 41                 325                 368                 882            \n",
       "118 64                 247                 286                 882            \n",
       "123  0                   0                   3                 855            \n",
       "127 15                  98                 132                 882            \n",
       "131 28                  88                  94                 879            \n",
       "134  0                   0                   2                1335            \n",
       "138  0                   6                  28                1341            \n",
       "143  0                   0                   2                1341            \n",
       "155  0                   2                   9                1341            \n",
       "    min_overlap_snps mean_overlap_snps total_n\n",
       "2    381              381.0000          35    \n",
       "8    368              380.7734         372    \n",
       "14   367              380.6307         293    \n",
       "24   379              380.9685         132    \n",
       "28   379              379.0000          96    \n",
       "105  876              877.9394          35    \n",
       "111  835              881.1541         372    \n",
       "118  831              880.4567         293    \n",
       "123  855              855.0000           3    \n",
       "127  879              881.9545         132    \n",
       "131  879              879.0000          96    \n",
       "134 1332             1334.2500          35    \n",
       "138 1273             1337.0882         372    \n",
       "143 1341             1341.0000         293    \n",
       "155 1334             1340.2222         132    "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "overview_h_amounts[(overview_h_amounts$egene %in%  c('CD4T_RPS26', 'CD8T_RPS26', 'monocyte_RPS26', 'DC_RPS26', 'NK_RPS26','B_RPS26')) & (overview_h_amounts$parameter %in% c('PP.H4.abf')),]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "id": "8892fdf4-cb58-4887-847f-cc1aa744ae37",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 7 × 12</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>trait</th><th scope=col>egene</th><th scope=col>parameter</th><th scope=col>n</th><th scope=col>mean_value</th><th scope=col>amount_greater_0.9</th><th scope=col>amount_greater_0.75</th><th scope=col>amount_greater_0.5</th><th scope=col>max_overlap_snps</th><th scope=col>min_overlap_snps</th><th scope=col>mean_overlap_snps</th><th scope=col>total_n</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;int&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>110</th><td>Rheumatoid Arthritis</td><td>CD4T_RPS26    </td><td>PP.H3.abf</td><td>  2</td><td>0.6476383</td><td>  0</td><td>  0</td><td>  2</td><td> 882</td><td> 882</td><td> 882.000</td><td>372</td></tr>\n",
       "\t<tr><th scope=row>133</th><td>Type_1_Diabetes     </td><td>B_RPS26       </td><td>PP.H3.abf</td><td> 24</td><td>0.7354662</td><td>  7</td><td> 12</td><td> 20</td><td>1335</td><td>1335</td><td>1335.000</td><td> 35</td></tr>\n",
       "\t<tr><th scope=row>139</th><td>Type_1_Diabetes     </td><td>CD4T_RPS26    </td><td>PP.H3.abf</td><td>336</td><td>0.9025018</td><td>234</td><td>282</td><td>329</td><td>1341</td><td>1274</td><td>1339.973</td><td>372</td></tr>\n",
       "\t<tr><th scope=row>144</th><td>Type_1_Diabetes     </td><td>CD8T_RPS26    </td><td>PP.H3.abf</td><td>266</td><td>0.9176685</td><td>204</td><td>223</td><td>258</td><td>1341</td><td>1268</td><td>1339.011</td><td>293</td></tr>\n",
       "\t<tr><th scope=row>150</th><td>Type_1_Diabetes     </td><td>DC_RPS26      </td><td>PP.H3.abf</td><td>  1</td><td>0.4908023</td><td>  0</td><td>  0</td><td>  0</td><td>1297</td><td>1297</td><td>1297.000</td><td>  3</td></tr>\n",
       "\t<tr><th scope=row>154</th><td>Type_1_Diabetes     </td><td>monocyte_RPS26</td><td>PP.H3.abf</td><td>122</td><td>0.9210668</td><td> 92</td><td>109</td><td>119</td><td>1341</td><td>1334</td><td>1340.934</td><td>132</td></tr>\n",
       "\t<tr><th scope=row>159</th><td>Type_1_Diabetes     </td><td>NK_RPS26      </td><td>PP.H3.abf</td><td> 91</td><td>0.9621223</td><td> 81</td><td> 87</td><td> 90</td><td>1334</td><td>1334</td><td>1334.000</td><td> 96</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 7 × 12\n",
       "\\begin{tabular}{r|llllllllllll}\n",
       "  & trait & egene & parameter & n & mean\\_value & amount\\_greater\\_0.9 & amount\\_greater\\_0.75 & amount\\_greater\\_0.5 & max\\_overlap\\_snps & min\\_overlap\\_snps & mean\\_overlap\\_snps & total\\_n\\\\\n",
       "  & <chr> & <chr> & <chr> & <int> & <dbl> & <int> & <int> & <int> & <dbl> & <dbl> & <dbl> & <int>\\\\\n",
       "\\hline\n",
       "\t110 & Rheumatoid Arthritis & CD4T\\_RPS26     & PP.H3.abf &   2 & 0.6476383 &   0 &   0 &   2 &  882 &  882 &  882.000 & 372\\\\\n",
       "\t133 & Type\\_1\\_Diabetes      & B\\_RPS26        & PP.H3.abf &  24 & 0.7354662 &   7 &  12 &  20 & 1335 & 1335 & 1335.000 &  35\\\\\n",
       "\t139 & Type\\_1\\_Diabetes      & CD4T\\_RPS26     & PP.H3.abf & 336 & 0.9025018 & 234 & 282 & 329 & 1341 & 1274 & 1339.973 & 372\\\\\n",
       "\t144 & Type\\_1\\_Diabetes      & CD8T\\_RPS26     & PP.H3.abf & 266 & 0.9176685 & 204 & 223 & 258 & 1341 & 1268 & 1339.011 & 293\\\\\n",
       "\t150 & Type\\_1\\_Diabetes      & DC\\_RPS26       & PP.H3.abf &   1 & 0.4908023 &   0 &   0 &   0 & 1297 & 1297 & 1297.000 &   3\\\\\n",
       "\t154 & Type\\_1\\_Diabetes      & monocyte\\_RPS26 & PP.H3.abf & 122 & 0.9210668 &  92 & 109 & 119 & 1341 & 1334 & 1340.934 & 132\\\\\n",
       "\t159 & Type\\_1\\_Diabetes      & NK\\_RPS26       & PP.H3.abf &  91 & 0.9621223 &  81 &  87 &  90 & 1334 & 1334 & 1334.000 &  96\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 7 × 12\n",
       "\n",
       "| <!--/--> | trait &lt;chr&gt; | egene &lt;chr&gt; | parameter &lt;chr&gt; | n &lt;int&gt; | mean_value &lt;dbl&gt; | amount_greater_0.9 &lt;int&gt; | amount_greater_0.75 &lt;int&gt; | amount_greater_0.5 &lt;int&gt; | max_overlap_snps &lt;dbl&gt; | min_overlap_snps &lt;dbl&gt; | mean_overlap_snps &lt;dbl&gt; | total_n &lt;int&gt; |\n",
       "|---|---|---|---|---|---|---|---|---|---|---|---|---|\n",
       "| 110 | Rheumatoid Arthritis | CD4T_RPS26     | PP.H3.abf |   2 | 0.6476383 |   0 |   0 |   2 |  882 |  882 |  882.000 | 372 |\n",
       "| 133 | Type_1_Diabetes      | B_RPS26        | PP.H3.abf |  24 | 0.7354662 |   7 |  12 |  20 | 1335 | 1335 | 1335.000 |  35 |\n",
       "| 139 | Type_1_Diabetes      | CD4T_RPS26     | PP.H3.abf | 336 | 0.9025018 | 234 | 282 | 329 | 1341 | 1274 | 1339.973 | 372 |\n",
       "| 144 | Type_1_Diabetes      | CD8T_RPS26     | PP.H3.abf | 266 | 0.9176685 | 204 | 223 | 258 | 1341 | 1268 | 1339.011 | 293 |\n",
       "| 150 | Type_1_Diabetes      | DC_RPS26       | PP.H3.abf |   1 | 0.4908023 |   0 |   0 |   0 | 1297 | 1297 | 1297.000 |   3 |\n",
       "| 154 | Type_1_Diabetes      | monocyte_RPS26 | PP.H3.abf | 122 | 0.9210668 |  92 | 109 | 119 | 1341 | 1334 | 1340.934 | 132 |\n",
       "| 159 | Type_1_Diabetes      | NK_RPS26       | PP.H3.abf |  91 | 0.9621223 |  81 |  87 |  90 | 1334 | 1334 | 1334.000 |  96 |\n",
       "\n"
      ],
      "text/plain": [
       "    trait                egene          parameter n   mean_value\n",
       "110 Rheumatoid Arthritis CD4T_RPS26     PP.H3.abf   2 0.6476383 \n",
       "133 Type_1_Diabetes      B_RPS26        PP.H3.abf  24 0.7354662 \n",
       "139 Type_1_Diabetes      CD4T_RPS26     PP.H3.abf 336 0.9025018 \n",
       "144 Type_1_Diabetes      CD8T_RPS26     PP.H3.abf 266 0.9176685 \n",
       "150 Type_1_Diabetes      DC_RPS26       PP.H3.abf   1 0.4908023 \n",
       "154 Type_1_Diabetes      monocyte_RPS26 PP.H3.abf 122 0.9210668 \n",
       "159 Type_1_Diabetes      NK_RPS26       PP.H3.abf  91 0.9621223 \n",
       "    amount_greater_0.9 amount_greater_0.75 amount_greater_0.5 max_overlap_snps\n",
       "110   0                  0                   2                 882            \n",
       "133   7                 12                  20                1335            \n",
       "139 234                282                 329                1341            \n",
       "144 204                223                 258                1341            \n",
       "150   0                  0                   0                1297            \n",
       "154  92                109                 119                1341            \n",
       "159  81                 87                  90                1334            \n",
       "    min_overlap_snps mean_overlap_snps total_n\n",
       "110  882              882.000          372    \n",
       "133 1335             1335.000           35    \n",
       "139 1274             1339.973          372    \n",
       "144 1268             1339.011          293    \n",
       "150 1297             1297.000            3    \n",
       "154 1334             1340.934          132    \n",
       "159 1334             1334.000           96    "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "overview_h_amounts[(overview_h_amounts$egene %in%  c('CD4T_RPS26', 'CD8T_RPS26', 'monocyte_RPS26', 'DC_RPS26', 'NK_RPS26','B_RPS26')) & (overview_h_amounts$parameter %in% c( 'PP.H3.abf')),]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "id": "c484189b-0860-452d-a2c8-0b3fd0e92493",
   "metadata": {},
   "outputs": [],
   "source": [
    "### All HLA-DQA2  - co-egene examples"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "id": "1b9cd94a-04fd-4e2d-abb8-9bb3fffcc2f9",
   "metadata": {},
   "outputs": [],
   "source": [
    "#unique(overview_h_amounts$egene )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "id": "efef7428-1374-453c-a65d-9c68313bde68",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 24 × 12</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>trait</th><th scope=col>egene</th><th scope=col>parameter</th><th scope=col>n</th><th scope=col>mean_value</th><th scope=col>amount_greater_0.9</th><th scope=col>amount_greater_0.75</th><th scope=col>amount_greater_0.5</th><th scope=col>max_overlap_snps</th><th scope=col>min_overlap_snps</th><th scope=col>mean_overlap_snps</th><th scope=col>total_n</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;int&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>3</th><td>Asthma                    </td><td>CD4T_HLA-DQA2    </td><td>PP.H4.abf</td><td>13</td><td>0.8605121</td><td> 5</td><td>11</td><td>13</td><td> 387</td><td> 387</td><td> 387.0000</td><td>16</td></tr>\n",
       "\t<tr><th scope=row>11</th><td>Asthma                    </td><td>CD8T_HLA-DQA2    </td><td>PP.H4.abf</td><td> 7</td><td>0.8719882</td><td> 5</td><td> 5</td><td> 7</td><td> 386</td><td> 386</td><td> 386.0000</td><td> 7</td></tr>\n",
       "\t<tr><th scope=row>18</th><td>Asthma                    </td><td>DC_HLA-DQA2      </td><td>PP.H4.abf</td><td> 5</td><td>0.6734167</td><td> 0</td><td> 1</td><td> 5</td><td> 358</td><td> 348</td><td> 351.8000</td><td>13</td></tr>\n",
       "\t<tr><th scope=row>20</th><td>Asthma                    </td><td>monocyte_HLA-DQA2</td><td>PP.H4.abf</td><td> 4</td><td>0.7193509</td><td> 1</td><td> 2</td><td> 4</td><td> 388</td><td> 388</td><td> 388.0000</td><td>17</td></tr>\n",
       "\t<tr><th scope=row>32</th><td>Crohn's Disease           </td><td>CD4T_HLA-DQA2    </td><td>PP.H3.abf</td><td>16</td><td>0.8674851</td><td> 8</td><td>14</td><td>16</td><td>4525</td><td>4525</td><td>4525.0000</td><td>16</td></tr>\n",
       "\t<tr><th scope=row>39</th><td>Crohn's Disease           </td><td>CD8T_HLA-DQA2    </td><td>PP.H3.abf</td><td> 7</td><td>0.8685034</td><td> 2</td><td> 6</td><td> 7</td><td>4491</td><td>4383</td><td>4475.5714</td><td> 7</td></tr>\n",
       "\t<tr><th scope=row>45</th><td>Crohn's Disease           </td><td>DC_HLA-DQA2      </td><td>PP.H3.abf</td><td> 9</td><td>0.6909695</td><td> 0</td><td> 3</td><td> 9</td><td>3930</td><td>3758</td><td>3810.6667</td><td>13</td></tr>\n",
       "\t<tr><th scope=row>47</th><td>Crohn's Disease           </td><td>monocyte_HLA-DQA2</td><td>PP.H3.abf</td><td>17</td><td>0.9558094</td><td>14</td><td>17</td><td>17</td><td>4436</td><td>4331</td><td>4363.8235</td><td>17</td></tr>\n",
       "\t<tr><th scope=row>57</th><td>Inflammatory Bowel Disease</td><td>CD4T_HLA-DQA2    </td><td>PP.H3.abf</td><td>16</td><td>0.7763020</td><td> 1</td><td> 9</td><td>16</td><td>4527</td><td>4527</td><td>4527.0000</td><td>16</td></tr>\n",
       "\t<tr><th scope=row>63</th><td>Inflammatory Bowel Disease</td><td>CD8T_HLA-DQA2    </td><td>PP.H3.abf</td><td> 7</td><td>0.8173129</td><td> 1</td><td> 5</td><td> 7</td><td>4493</td><td>4385</td><td>4477.5714</td><td> 7</td></tr>\n",
       "\t<tr><th scope=row>69</th><td>Inflammatory Bowel Disease</td><td>DC_HLA-DQA2      </td><td>PP.H3.abf</td><td> 9</td><td>0.6542293</td><td> 0</td><td> 3</td><td> 9</td><td>3932</td><td>3760</td><td>3812.4444</td><td>13</td></tr>\n",
       "\t<tr><th scope=row>71</th><td>Inflammatory Bowel Disease</td><td>monocyte_HLA-DQA2</td><td>PP.H3.abf</td><td>17</td><td>0.8218316</td><td> 4</td><td>12</td><td>17</td><td>4438</td><td>4333</td><td>4365.8235</td><td>17</td></tr>\n",
       "\t<tr><th scope=row>82</th><td>Multiple Sclerosis        </td><td>CD4T_HLA-DQA2    </td><td>PP.H4.abf</td><td> 1</td><td>0.9211400</td><td> 1</td><td> 1</td><td> 1</td><td>  50</td><td>  50</td><td>  50.0000</td><td>16</td></tr>\n",
       "\t<tr><th scope=row>96</th><td>Multiple Sclerosis        </td><td>monocyte_HLA-DQA2</td><td>PP.H4.abf</td><td> 1</td><td>0.7952340</td><td> 0</td><td> 1</td><td> 1</td><td>  50</td><td>  50</td><td>  50.0000</td><td>17</td></tr>\n",
       "\t<tr><th scope=row>106</th><td>Rheumatoid Arthritis      </td><td>CD4T_HLA-DQA2    </td><td>PP.H4.abf</td><td>10</td><td>0.5554058</td><td> 0</td><td> 0</td><td> 7</td><td> 819</td><td> 819</td><td> 819.0000</td><td>16</td></tr>\n",
       "\t<tr><th scope=row>108</th><td>Rheumatoid Arthritis      </td><td>CD4T_HLA-DQA2    </td><td>PP.H3.abf</td><td> 5</td><td>0.6100632</td><td> 0</td><td> 1</td><td> 4</td><td> 819</td><td> 819</td><td> 819.0000</td><td>16</td></tr>\n",
       "\t<tr><th scope=row>114</th><td>Rheumatoid Arthritis      </td><td>CD8T_HLA-DQA2    </td><td>PP.H4.abf</td><td> 1</td><td>0.4211959</td><td> 0</td><td> 0</td><td> 0</td><td> 801</td><td> 801</td><td> 801.0000</td><td> 7</td></tr>\n",
       "\t<tr><th scope=row>115</th><td>Rheumatoid Arthritis      </td><td>CD8T_HLA-DQA2    </td><td>PP.H3.abf</td><td> 5</td><td>0.5385873</td><td> 0</td><td> 1</td><td> 3</td><td> 817</td><td> 817</td><td> 817.0000</td><td> 7</td></tr>\n",
       "\t<tr><th scope=row>122</th><td>Rheumatoid Arthritis      </td><td>DC_HLA-DQA2      </td><td>PP.H4.abf</td><td> 1</td><td>0.4800992</td><td> 0</td><td> 0</td><td> 0</td><td> 706</td><td> 706</td><td> 706.0000</td><td>13</td></tr>\n",
       "\t<tr><th scope=row>125</th><td>Rheumatoid Arthritis      </td><td>monocyte_HLA-DQA2</td><td>PP.H4.abf</td><td>16</td><td>0.6159706</td><td> 0</td><td> 0</td><td>14</td><td> 817</td><td> 815</td><td> 815.8125</td><td>17</td></tr>\n",
       "\t<tr><th scope=row>135</th><td>Type_1_Diabetes           </td><td>CD4T_HLA-DQA2    </td><td>PP.H3.abf</td><td>16</td><td>0.7585537</td><td> 2</td><td> 9</td><td>16</td><td>1319</td><td>1319</td><td>1319.0000</td><td>16</td></tr>\n",
       "\t<tr><th scope=row>142</th><td>Type_1_Diabetes           </td><td>CD8T_HLA-DQA2    </td><td>PP.H3.abf</td><td> 7</td><td>0.7726785</td><td> 2</td><td> 4</td><td> 6</td><td>1317</td><td>1282</td><td>1312.0000</td><td> 7</td></tr>\n",
       "\t<tr><th scope=row>148</th><td>Type_1_Diabetes           </td><td>DC_HLA-DQA2      </td><td>PP.H3.abf</td><td> 3</td><td>0.5865191</td><td> 0</td><td> 0</td><td> 3</td><td>1115</td><td>1115</td><td>1115.0000</td><td>13</td></tr>\n",
       "\t<tr><th scope=row>152</th><td>Type_1_Diabetes           </td><td>monocyte_HLA-DQA2</td><td>PP.H3.abf</td><td>17</td><td>0.9371937</td><td>13</td><td>16</td><td>17</td><td>1300</td><td>1289</td><td>1292.4706</td><td>17</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 24 × 12\n",
       "\\begin{tabular}{r|llllllllllll}\n",
       "  & trait & egene & parameter & n & mean\\_value & amount\\_greater\\_0.9 & amount\\_greater\\_0.75 & amount\\_greater\\_0.5 & max\\_overlap\\_snps & min\\_overlap\\_snps & mean\\_overlap\\_snps & total\\_n\\\\\n",
       "  & <chr> & <chr> & <chr> & <int> & <dbl> & <int> & <int> & <int> & <dbl> & <dbl> & <dbl> & <int>\\\\\n",
       "\\hline\n",
       "\t3 & Asthma                     & CD4T\\_HLA-DQA2     & PP.H4.abf & 13 & 0.8605121 &  5 & 11 & 13 &  387 &  387 &  387.0000 & 16\\\\\n",
       "\t11 & Asthma                     & CD8T\\_HLA-DQA2     & PP.H4.abf &  7 & 0.8719882 &  5 &  5 &  7 &  386 &  386 &  386.0000 &  7\\\\\n",
       "\t18 & Asthma                     & DC\\_HLA-DQA2       & PP.H4.abf &  5 & 0.6734167 &  0 &  1 &  5 &  358 &  348 &  351.8000 & 13\\\\\n",
       "\t20 & Asthma                     & monocyte\\_HLA-DQA2 & PP.H4.abf &  4 & 0.7193509 &  1 &  2 &  4 &  388 &  388 &  388.0000 & 17\\\\\n",
       "\t32 & Crohn's Disease            & CD4T\\_HLA-DQA2     & PP.H3.abf & 16 & 0.8674851 &  8 & 14 & 16 & 4525 & 4525 & 4525.0000 & 16\\\\\n",
       "\t39 & Crohn's Disease            & CD8T\\_HLA-DQA2     & PP.H3.abf &  7 & 0.8685034 &  2 &  6 &  7 & 4491 & 4383 & 4475.5714 &  7\\\\\n",
       "\t45 & Crohn's Disease            & DC\\_HLA-DQA2       & PP.H3.abf &  9 & 0.6909695 &  0 &  3 &  9 & 3930 & 3758 & 3810.6667 & 13\\\\\n",
       "\t47 & Crohn's Disease            & monocyte\\_HLA-DQA2 & PP.H3.abf & 17 & 0.9558094 & 14 & 17 & 17 & 4436 & 4331 & 4363.8235 & 17\\\\\n",
       "\t57 & Inflammatory Bowel Disease & CD4T\\_HLA-DQA2     & PP.H3.abf & 16 & 0.7763020 &  1 &  9 & 16 & 4527 & 4527 & 4527.0000 & 16\\\\\n",
       "\t63 & Inflammatory Bowel Disease & CD8T\\_HLA-DQA2     & PP.H3.abf &  7 & 0.8173129 &  1 &  5 &  7 & 4493 & 4385 & 4477.5714 &  7\\\\\n",
       "\t69 & Inflammatory Bowel Disease & DC\\_HLA-DQA2       & PP.H3.abf &  9 & 0.6542293 &  0 &  3 &  9 & 3932 & 3760 & 3812.4444 & 13\\\\\n",
       "\t71 & Inflammatory Bowel Disease & monocyte\\_HLA-DQA2 & PP.H3.abf & 17 & 0.8218316 &  4 & 12 & 17 & 4438 & 4333 & 4365.8235 & 17\\\\\n",
       "\t82 & Multiple Sclerosis         & CD4T\\_HLA-DQA2     & PP.H4.abf &  1 & 0.9211400 &  1 &  1 &  1 &   50 &   50 &   50.0000 & 16\\\\\n",
       "\t96 & Multiple Sclerosis         & monocyte\\_HLA-DQA2 & PP.H4.abf &  1 & 0.7952340 &  0 &  1 &  1 &   50 &   50 &   50.0000 & 17\\\\\n",
       "\t106 & Rheumatoid Arthritis       & CD4T\\_HLA-DQA2     & PP.H4.abf & 10 & 0.5554058 &  0 &  0 &  7 &  819 &  819 &  819.0000 & 16\\\\\n",
       "\t108 & Rheumatoid Arthritis       & CD4T\\_HLA-DQA2     & PP.H3.abf &  5 & 0.6100632 &  0 &  1 &  4 &  819 &  819 &  819.0000 & 16\\\\\n",
       "\t114 & Rheumatoid Arthritis       & CD8T\\_HLA-DQA2     & PP.H4.abf &  1 & 0.4211959 &  0 &  0 &  0 &  801 &  801 &  801.0000 &  7\\\\\n",
       "\t115 & Rheumatoid Arthritis       & CD8T\\_HLA-DQA2     & PP.H3.abf &  5 & 0.5385873 &  0 &  1 &  3 &  817 &  817 &  817.0000 &  7\\\\\n",
       "\t122 & Rheumatoid Arthritis       & DC\\_HLA-DQA2       & PP.H4.abf &  1 & 0.4800992 &  0 &  0 &  0 &  706 &  706 &  706.0000 & 13\\\\\n",
       "\t125 & Rheumatoid Arthritis       & monocyte\\_HLA-DQA2 & PP.H4.abf & 16 & 0.6159706 &  0 &  0 & 14 &  817 &  815 &  815.8125 & 17\\\\\n",
       "\t135 & Type\\_1\\_Diabetes            & CD4T\\_HLA-DQA2     & PP.H3.abf & 16 & 0.7585537 &  2 &  9 & 16 & 1319 & 1319 & 1319.0000 & 16\\\\\n",
       "\t142 & Type\\_1\\_Diabetes            & CD8T\\_HLA-DQA2     & PP.H3.abf &  7 & 0.7726785 &  2 &  4 &  6 & 1317 & 1282 & 1312.0000 &  7\\\\\n",
       "\t148 & Type\\_1\\_Diabetes            & DC\\_HLA-DQA2       & PP.H3.abf &  3 & 0.5865191 &  0 &  0 &  3 & 1115 & 1115 & 1115.0000 & 13\\\\\n",
       "\t152 & Type\\_1\\_Diabetes            & monocyte\\_HLA-DQA2 & PP.H3.abf & 17 & 0.9371937 & 13 & 16 & 17 & 1300 & 1289 & 1292.4706 & 17\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 24 × 12\n",
       "\n",
       "| <!--/--> | trait &lt;chr&gt; | egene &lt;chr&gt; | parameter &lt;chr&gt; | n &lt;int&gt; | mean_value &lt;dbl&gt; | amount_greater_0.9 &lt;int&gt; | amount_greater_0.75 &lt;int&gt; | amount_greater_0.5 &lt;int&gt; | max_overlap_snps &lt;dbl&gt; | min_overlap_snps &lt;dbl&gt; | mean_overlap_snps &lt;dbl&gt; | total_n &lt;int&gt; |\n",
       "|---|---|---|---|---|---|---|---|---|---|---|---|---|\n",
       "| 3 | Asthma                     | CD4T_HLA-DQA2     | PP.H4.abf | 13 | 0.8605121 |  5 | 11 | 13 |  387 |  387 |  387.0000 | 16 |\n",
       "| 11 | Asthma                     | CD8T_HLA-DQA2     | PP.H4.abf |  7 | 0.8719882 |  5 |  5 |  7 |  386 |  386 |  386.0000 |  7 |\n",
       "| 18 | Asthma                     | DC_HLA-DQA2       | PP.H4.abf |  5 | 0.6734167 |  0 |  1 |  5 |  358 |  348 |  351.8000 | 13 |\n",
       "| 20 | Asthma                     | monocyte_HLA-DQA2 | PP.H4.abf |  4 | 0.7193509 |  1 |  2 |  4 |  388 |  388 |  388.0000 | 17 |\n",
       "| 32 | Crohn's Disease            | CD4T_HLA-DQA2     | PP.H3.abf | 16 | 0.8674851 |  8 | 14 | 16 | 4525 | 4525 | 4525.0000 | 16 |\n",
       "| 39 | Crohn's Disease            | CD8T_HLA-DQA2     | PP.H3.abf |  7 | 0.8685034 |  2 |  6 |  7 | 4491 | 4383 | 4475.5714 |  7 |\n",
       "| 45 | Crohn's Disease            | DC_HLA-DQA2       | PP.H3.abf |  9 | 0.6909695 |  0 |  3 |  9 | 3930 | 3758 | 3810.6667 | 13 |\n",
       "| 47 | Crohn's Disease            | monocyte_HLA-DQA2 | PP.H3.abf | 17 | 0.9558094 | 14 | 17 | 17 | 4436 | 4331 | 4363.8235 | 17 |\n",
       "| 57 | Inflammatory Bowel Disease | CD4T_HLA-DQA2     | PP.H3.abf | 16 | 0.7763020 |  1 |  9 | 16 | 4527 | 4527 | 4527.0000 | 16 |\n",
       "| 63 | Inflammatory Bowel Disease | CD8T_HLA-DQA2     | PP.H3.abf |  7 | 0.8173129 |  1 |  5 |  7 | 4493 | 4385 | 4477.5714 |  7 |\n",
       "| 69 | Inflammatory Bowel Disease | DC_HLA-DQA2       | PP.H3.abf |  9 | 0.6542293 |  0 |  3 |  9 | 3932 | 3760 | 3812.4444 | 13 |\n",
       "| 71 | Inflammatory Bowel Disease | monocyte_HLA-DQA2 | PP.H3.abf | 17 | 0.8218316 |  4 | 12 | 17 | 4438 | 4333 | 4365.8235 | 17 |\n",
       "| 82 | Multiple Sclerosis         | CD4T_HLA-DQA2     | PP.H4.abf |  1 | 0.9211400 |  1 |  1 |  1 |   50 |   50 |   50.0000 | 16 |\n",
       "| 96 | Multiple Sclerosis         | monocyte_HLA-DQA2 | PP.H4.abf |  1 | 0.7952340 |  0 |  1 |  1 |   50 |   50 |   50.0000 | 17 |\n",
       "| 106 | Rheumatoid Arthritis       | CD4T_HLA-DQA2     | PP.H4.abf | 10 | 0.5554058 |  0 |  0 |  7 |  819 |  819 |  819.0000 | 16 |\n",
       "| 108 | Rheumatoid Arthritis       | CD4T_HLA-DQA2     | PP.H3.abf |  5 | 0.6100632 |  0 |  1 |  4 |  819 |  819 |  819.0000 | 16 |\n",
       "| 114 | Rheumatoid Arthritis       | CD8T_HLA-DQA2     | PP.H4.abf |  1 | 0.4211959 |  0 |  0 |  0 |  801 |  801 |  801.0000 |  7 |\n",
       "| 115 | Rheumatoid Arthritis       | CD8T_HLA-DQA2     | PP.H3.abf |  5 | 0.5385873 |  0 |  1 |  3 |  817 |  817 |  817.0000 |  7 |\n",
       "| 122 | Rheumatoid Arthritis       | DC_HLA-DQA2       | PP.H4.abf |  1 | 0.4800992 |  0 |  0 |  0 |  706 |  706 |  706.0000 | 13 |\n",
       "| 125 | Rheumatoid Arthritis       | monocyte_HLA-DQA2 | PP.H4.abf | 16 | 0.6159706 |  0 |  0 | 14 |  817 |  815 |  815.8125 | 17 |\n",
       "| 135 | Type_1_Diabetes            | CD4T_HLA-DQA2     | PP.H3.abf | 16 | 0.7585537 |  2 |  9 | 16 | 1319 | 1319 | 1319.0000 | 16 |\n",
       "| 142 | Type_1_Diabetes            | CD8T_HLA-DQA2     | PP.H3.abf |  7 | 0.7726785 |  2 |  4 |  6 | 1317 | 1282 | 1312.0000 |  7 |\n",
       "| 148 | Type_1_Diabetes            | DC_HLA-DQA2       | PP.H3.abf |  3 | 0.5865191 |  0 |  0 |  3 | 1115 | 1115 | 1115.0000 | 13 |\n",
       "| 152 | Type_1_Diabetes            | monocyte_HLA-DQA2 | PP.H3.abf | 17 | 0.9371937 | 13 | 16 | 17 | 1300 | 1289 | 1292.4706 | 17 |\n",
       "\n"
      ],
      "text/plain": [
       "    trait                      egene             parameter n  mean_value\n",
       "3   Asthma                     CD4T_HLA-DQA2     PP.H4.abf 13 0.8605121 \n",
       "11  Asthma                     CD8T_HLA-DQA2     PP.H4.abf  7 0.8719882 \n",
       "18  Asthma                     DC_HLA-DQA2       PP.H4.abf  5 0.6734167 \n",
       "20  Asthma                     monocyte_HLA-DQA2 PP.H4.abf  4 0.7193509 \n",
       "32  Crohn's Disease            CD4T_HLA-DQA2     PP.H3.abf 16 0.8674851 \n",
       "39  Crohn's Disease            CD8T_HLA-DQA2     PP.H3.abf  7 0.8685034 \n",
       "45  Crohn's Disease            DC_HLA-DQA2       PP.H3.abf  9 0.6909695 \n",
       "47  Crohn's Disease            monocyte_HLA-DQA2 PP.H3.abf 17 0.9558094 \n",
       "57  Inflammatory Bowel Disease CD4T_HLA-DQA2     PP.H3.abf 16 0.7763020 \n",
       "63  Inflammatory Bowel Disease CD8T_HLA-DQA2     PP.H3.abf  7 0.8173129 \n",
       "69  Inflammatory Bowel Disease DC_HLA-DQA2       PP.H3.abf  9 0.6542293 \n",
       "71  Inflammatory Bowel Disease monocyte_HLA-DQA2 PP.H3.abf 17 0.8218316 \n",
       "82  Multiple Sclerosis         CD4T_HLA-DQA2     PP.H4.abf  1 0.9211400 \n",
       "96  Multiple Sclerosis         monocyte_HLA-DQA2 PP.H4.abf  1 0.7952340 \n",
       "106 Rheumatoid Arthritis       CD4T_HLA-DQA2     PP.H4.abf 10 0.5554058 \n",
       "108 Rheumatoid Arthritis       CD4T_HLA-DQA2     PP.H3.abf  5 0.6100632 \n",
       "114 Rheumatoid Arthritis       CD8T_HLA-DQA2     PP.H4.abf  1 0.4211959 \n",
       "115 Rheumatoid Arthritis       CD8T_HLA-DQA2     PP.H3.abf  5 0.5385873 \n",
       "122 Rheumatoid Arthritis       DC_HLA-DQA2       PP.H4.abf  1 0.4800992 \n",
       "125 Rheumatoid Arthritis       monocyte_HLA-DQA2 PP.H4.abf 16 0.6159706 \n",
       "135 Type_1_Diabetes            CD4T_HLA-DQA2     PP.H3.abf 16 0.7585537 \n",
       "142 Type_1_Diabetes            CD8T_HLA-DQA2     PP.H3.abf  7 0.7726785 \n",
       "148 Type_1_Diabetes            DC_HLA-DQA2       PP.H3.abf  3 0.5865191 \n",
       "152 Type_1_Diabetes            monocyte_HLA-DQA2 PP.H3.abf 17 0.9371937 \n",
       "    amount_greater_0.9 amount_greater_0.75 amount_greater_0.5 max_overlap_snps\n",
       "3    5                 11                  13                  387            \n",
       "11   5                  5                   7                  386            \n",
       "18   0                  1                   5                  358            \n",
       "20   1                  2                   4                  388            \n",
       "32   8                 14                  16                 4525            \n",
       "39   2                  6                   7                 4491            \n",
       "45   0                  3                   9                 3930            \n",
       "47  14                 17                  17                 4436            \n",
       "57   1                  9                  16                 4527            \n",
       "63   1                  5                   7                 4493            \n",
       "69   0                  3                   9                 3932            \n",
       "71   4                 12                  17                 4438            \n",
       "82   1                  1                   1                   50            \n",
       "96   0                  1                   1                   50            \n",
       "106  0                  0                   7                  819            \n",
       "108  0                  1                   4                  819            \n",
       "114  0                  0                   0                  801            \n",
       "115  0                  1                   3                  817            \n",
       "122  0                  0                   0                  706            \n",
       "125  0                  0                  14                  817            \n",
       "135  2                  9                  16                 1319            \n",
       "142  2                  4                   6                 1317            \n",
       "148  0                  0                   3                 1115            \n",
       "152 13                 16                  17                 1300            \n",
       "    min_overlap_snps mean_overlap_snps total_n\n",
       "3    387              387.0000         16     \n",
       "11   386              386.0000          7     \n",
       "18   348              351.8000         13     \n",
       "20   388              388.0000         17     \n",
       "32  4525             4525.0000         16     \n",
       "39  4383             4475.5714          7     \n",
       "45  3758             3810.6667         13     \n",
       "47  4331             4363.8235         17     \n",
       "57  4527             4527.0000         16     \n",
       "63  4385             4477.5714          7     \n",
       "69  3760             3812.4444         13     \n",
       "71  4333             4365.8235         17     \n",
       "82    50               50.0000         16     \n",
       "96    50               50.0000         17     \n",
       "106  819              819.0000         16     \n",
       "108  819              819.0000         16     \n",
       "114  801              801.0000          7     \n",
       "115  817              817.0000          7     \n",
       "122  706              706.0000         13     \n",
       "125  815              815.8125         17     \n",
       "135 1319             1319.0000         16     \n",
       "142 1282             1312.0000          7     \n",
       "148 1115             1115.0000         13     \n",
       "152 1289             1292.4706         17     "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "overview_h_amounts[(overview_h_amounts$egene %in% c('CD4T_HLA-DQA2' , 'CD8T_HLA-DQA2', 'monocyte_HLA-DQA2', 'DC_HLA-DQA2'))  & (overview_h_amounts$parameter %in% c('PP.H4.abf', 'PP.H3.abf')),]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "id": "553b946a-6572-4f74-873b-fc2638551e85",
   "metadata": {},
   "outputs": [],
   "source": [
    "### All SMDT1  - co-egene examples"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "id": "e575afe8-2da1-4b46-ac20-6a8fd81b0c49",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 0 × 12</caption>\n",
       "<thead>\n",
       "\t<tr><th scope=col>trait</th><th scope=col>egene</th><th scope=col>parameter</th><th scope=col>n</th><th scope=col>mean_value</th><th scope=col>amount_greater_0.9</th><th scope=col>amount_greater_0.75</th><th scope=col>amount_greater_0.5</th><th scope=col>max_overlap_snps</th><th scope=col>min_overlap_snps</th><th scope=col>mean_overlap_snps</th><th scope=col>total_n</th></tr>\n",
       "\t<tr><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;int&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 0 × 12\n",
       "\\begin{tabular}{llllllllllll}\n",
       " trait & egene & parameter & n & mean\\_value & amount\\_greater\\_0.9 & amount\\_greater\\_0.75 & amount\\_greater\\_0.5 & max\\_overlap\\_snps & min\\_overlap\\_snps & mean\\_overlap\\_snps & total\\_n\\\\\n",
       " <chr> & <chr> & <chr> & <int> & <dbl> & <int> & <int> & <int> & <dbl> & <dbl> & <dbl> & <int>\\\\\n",
       "\\hline\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 0 × 12\n",
       "\n",
       "| trait &lt;chr&gt; | egene &lt;chr&gt; | parameter &lt;chr&gt; | n &lt;int&gt; | mean_value &lt;dbl&gt; | amount_greater_0.9 &lt;int&gt; | amount_greater_0.75 &lt;int&gt; | amount_greater_0.5 &lt;int&gt; | max_overlap_snps &lt;dbl&gt; | min_overlap_snps &lt;dbl&gt; | mean_overlap_snps &lt;dbl&gt; | total_n &lt;int&gt; |\n",
       "|---|---|---|---|---|---|---|---|---|---|---|---|\n",
       "\n"
      ],
      "text/plain": [
       "     trait egene parameter n mean_value amount_greater_0.9 amount_greater_0.75\n",
       "     amount_greater_0.5 max_overlap_snps min_overlap_snps mean_overlap_snps\n",
       "     total_n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "overview_h_amounts[(overview_h_amounts$egene %in%  c('CD4T_SMDT1', 'CD8T_SMDT1')) & (overview_h_amounts$parameter %in% c('PP.H4.abf', 'PP.H3.abf')),]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "id": "3ce6e5c0-f029-4051-b125-af8d6047ccf9",
   "metadata": {},
   "outputs": [],
   "source": [
    "### All TMEM176A  - co-egene examples"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "id": "4f8fac25-b1a9-4daa-80d4-a7a36464bcbc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 0 × 12</caption>\n",
       "<thead>\n",
       "\t<tr><th scope=col>trait</th><th scope=col>egene</th><th scope=col>parameter</th><th scope=col>n</th><th scope=col>mean_value</th><th scope=col>amount_greater_0.9</th><th scope=col>amount_greater_0.75</th><th scope=col>amount_greater_0.5</th><th scope=col>max_overlap_snps</th><th scope=col>min_overlap_snps</th><th scope=col>mean_overlap_snps</th><th scope=col>total_n</th></tr>\n",
       "\t<tr><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;int&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 0 × 12\n",
       "\\begin{tabular}{llllllllllll}\n",
       " trait & egene & parameter & n & mean\\_value & amount\\_greater\\_0.9 & amount\\_greater\\_0.75 & amount\\_greater\\_0.5 & max\\_overlap\\_snps & min\\_overlap\\_snps & mean\\_overlap\\_snps & total\\_n\\\\\n",
       " <chr> & <chr> & <chr> & <int> & <dbl> & <int> & <int> & <int> & <dbl> & <dbl> & <dbl> & <int>\\\\\n",
       "\\hline\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 0 × 12\n",
       "\n",
       "| trait &lt;chr&gt; | egene &lt;chr&gt; | parameter &lt;chr&gt; | n &lt;int&gt; | mean_value &lt;dbl&gt; | amount_greater_0.9 &lt;int&gt; | amount_greater_0.75 &lt;int&gt; | amount_greater_0.5 &lt;int&gt; | max_overlap_snps &lt;dbl&gt; | min_overlap_snps &lt;dbl&gt; | mean_overlap_snps &lt;dbl&gt; | total_n &lt;int&gt; |\n",
       "|---|---|---|---|---|---|---|---|---|---|---|---|\n",
       "\n"
      ],
      "text/plain": [
       "     trait egene parameter n mean_value amount_greater_0.9 amount_greater_0.75\n",
       "     amount_greater_0.5 max_overlap_snps min_overlap_snps mean_overlap_snps\n",
       "     total_n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "overview_h_amounts[(overview_h_amounts$egene %in%  c('monocyte_TMEM176A'))  & (overview_h_amounts$parameter %in% c('PP.H4.abf', 'PP.H3.abf')),]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "id": "0fc7ba1c-6fb4-4def-b2e5-206deaa3a101",
   "metadata": {},
   "outputs": [],
   "source": [
    "### All RNASET2 - co-egene examples"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "id": "78c7efed-46e2-4e17-a2f6-970497c695c9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 6 × 12</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>trait</th><th scope=col>egene</th><th scope=col>parameter</th><th scope=col>n</th><th scope=col>mean_value</th><th scope=col>amount_greater_0.9</th><th scope=col>amount_greater_0.75</th><th scope=col>amount_greater_0.5</th><th scope=col>max_overlap_snps</th><th scope=col>min_overlap_snps</th><th scope=col>mean_overlap_snps</th><th scope=col>total_n</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;int&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>33</th><td>Crohn's Disease           </td><td>CD4T_RNASET2    </td><td>PP.H3.abf</td><td>2</td><td>0.5193770</td><td>0</td><td>0</td><td>1</td><td>2707</td><td>2707</td><td>2707</td><td>4</td></tr>\n",
       "\t<tr><th scope=row>34</th><td>Crohn's Disease           </td><td>CD4T_RNASET2    </td><td>PP.H4.abf</td><td>2</td><td>0.5193536</td><td>0</td><td>0</td><td>2</td><td>2707</td><td>2707</td><td>2707</td><td>4</td></tr>\n",
       "\t<tr><th scope=row>48</th><td>Crohn's Disease           </td><td>monocyte_RNASET2</td><td>PP.H3.abf</td><td>1</td><td>0.8485668</td><td>0</td><td>1</td><td>1</td><td>4390</td><td>4390</td><td>4390</td><td>1</td></tr>\n",
       "\t<tr><th scope=row>58</th><td>Inflammatory Bowel Disease</td><td>CD4T_RNASET2    </td><td>PP.H3.abf</td><td>4</td><td>0.5968840</td><td>0</td><td>0</td><td>4</td><td>2704</td><td>2704</td><td>2704</td><td>4</td></tr>\n",
       "\t<tr><th scope=row>72</th><td>Inflammatory Bowel Disease</td><td>monocyte_RNASET2</td><td>PP.H3.abf</td><td>1</td><td>0.8485287</td><td>0</td><td>1</td><td>1</td><td>4391</td><td>4391</td><td>4391</td><td>1</td></tr>\n",
       "\t<tr><th scope=row>109</th><td>Rheumatoid Arthritis      </td><td>CD4T_RNASET2    </td><td>PP.H3.abf</td><td>4</td><td>0.9369664</td><td>3</td><td>4</td><td>4</td><td>2031</td><td>2031</td><td>2031</td><td>4</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 6 × 12\n",
       "\\begin{tabular}{r|llllllllllll}\n",
       "  & trait & egene & parameter & n & mean\\_value & amount\\_greater\\_0.9 & amount\\_greater\\_0.75 & amount\\_greater\\_0.5 & max\\_overlap\\_snps & min\\_overlap\\_snps & mean\\_overlap\\_snps & total\\_n\\\\\n",
       "  & <chr> & <chr> & <chr> & <int> & <dbl> & <int> & <int> & <int> & <dbl> & <dbl> & <dbl> & <int>\\\\\n",
       "\\hline\n",
       "\t33 & Crohn's Disease            & CD4T\\_RNASET2     & PP.H3.abf & 2 & 0.5193770 & 0 & 0 & 1 & 2707 & 2707 & 2707 & 4\\\\\n",
       "\t34 & Crohn's Disease            & CD4T\\_RNASET2     & PP.H4.abf & 2 & 0.5193536 & 0 & 0 & 2 & 2707 & 2707 & 2707 & 4\\\\\n",
       "\t48 & Crohn's Disease            & monocyte\\_RNASET2 & PP.H3.abf & 1 & 0.8485668 & 0 & 1 & 1 & 4390 & 4390 & 4390 & 1\\\\\n",
       "\t58 & Inflammatory Bowel Disease & CD4T\\_RNASET2     & PP.H3.abf & 4 & 0.5968840 & 0 & 0 & 4 & 2704 & 2704 & 2704 & 4\\\\\n",
       "\t72 & Inflammatory Bowel Disease & monocyte\\_RNASET2 & PP.H3.abf & 1 & 0.8485287 & 0 & 1 & 1 & 4391 & 4391 & 4391 & 1\\\\\n",
       "\t109 & Rheumatoid Arthritis       & CD4T\\_RNASET2     & PP.H3.abf & 4 & 0.9369664 & 3 & 4 & 4 & 2031 & 2031 & 2031 & 4\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 6 × 12\n",
       "\n",
       "| <!--/--> | trait &lt;chr&gt; | egene &lt;chr&gt; | parameter &lt;chr&gt; | n &lt;int&gt; | mean_value &lt;dbl&gt; | amount_greater_0.9 &lt;int&gt; | amount_greater_0.75 &lt;int&gt; | amount_greater_0.5 &lt;int&gt; | max_overlap_snps &lt;dbl&gt; | min_overlap_snps &lt;dbl&gt; | mean_overlap_snps &lt;dbl&gt; | total_n &lt;int&gt; |\n",
       "|---|---|---|---|---|---|---|---|---|---|---|---|---|\n",
       "| 33 | Crohn's Disease            | CD4T_RNASET2     | PP.H3.abf | 2 | 0.5193770 | 0 | 0 | 1 | 2707 | 2707 | 2707 | 4 |\n",
       "| 34 | Crohn's Disease            | CD4T_RNASET2     | PP.H4.abf | 2 | 0.5193536 | 0 | 0 | 2 | 2707 | 2707 | 2707 | 4 |\n",
       "| 48 | Crohn's Disease            | monocyte_RNASET2 | PP.H3.abf | 1 | 0.8485668 | 0 | 1 | 1 | 4390 | 4390 | 4390 | 1 |\n",
       "| 58 | Inflammatory Bowel Disease | CD4T_RNASET2     | PP.H3.abf | 4 | 0.5968840 | 0 | 0 | 4 | 2704 | 2704 | 2704 | 4 |\n",
       "| 72 | Inflammatory Bowel Disease | monocyte_RNASET2 | PP.H3.abf | 1 | 0.8485287 | 0 | 1 | 1 | 4391 | 4391 | 4391 | 1 |\n",
       "| 109 | Rheumatoid Arthritis       | CD4T_RNASET2     | PP.H3.abf | 4 | 0.9369664 | 3 | 4 | 4 | 2031 | 2031 | 2031 | 4 |\n",
       "\n"
      ],
      "text/plain": [
       "    trait                      egene            parameter n mean_value\n",
       "33  Crohn's Disease            CD4T_RNASET2     PP.H3.abf 2 0.5193770 \n",
       "34  Crohn's Disease            CD4T_RNASET2     PP.H4.abf 2 0.5193536 \n",
       "48  Crohn's Disease            monocyte_RNASET2 PP.H3.abf 1 0.8485668 \n",
       "58  Inflammatory Bowel Disease CD4T_RNASET2     PP.H3.abf 4 0.5968840 \n",
       "72  Inflammatory Bowel Disease monocyte_RNASET2 PP.H3.abf 1 0.8485287 \n",
       "109 Rheumatoid Arthritis       CD4T_RNASET2     PP.H3.abf 4 0.9369664 \n",
       "    amount_greater_0.9 amount_greater_0.75 amount_greater_0.5 max_overlap_snps\n",
       "33  0                  0                   1                  2707            \n",
       "34  0                  0                   2                  2707            \n",
       "48  0                  1                   1                  4390            \n",
       "58  0                  0                   4                  2704            \n",
       "72  0                  1                   1                  4391            \n",
       "109 3                  4                   4                  2031            \n",
       "    min_overlap_snps mean_overlap_snps total_n\n",
       "33  2707             2707              4      \n",
       "34  2707             2707              4      \n",
       "48  4390             4390              1      \n",
       "58  2704             2704              4      \n",
       "72  4391             4391              1      \n",
       "109 2031             2031              4      "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "overview_h_amounts[(overview_h_amounts$egene %in%  c('CD4T_RNASET2', 'monocyte_RNASET2')) & (overview_h_amounts$parameter %in% c('PP.H4.abf', 'PP.H3.abf')),]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "id": "fab6e933-d042-4133-af29-44c80e4ce21b",
   "metadata": {},
   "outputs": [],
   "source": [
    "#overview_h_amounts[order(overview_h_amounts$trait),]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "id": "e768d157-0704-486a-983f-7f8e56920126",
   "metadata": {},
   "outputs": [],
   "source": [
    "### Save supplementary table"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "id": "b7704adf-ab97-4153-9ef8-7fd8a28014c2",
   "metadata": {},
   "outputs": [],
   "source": [
    "coeqtl_supp = coeqtl_summary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "id": "6d779b12-1651-4484-af1d-84d2bc4f9b37",
   "metadata": {},
   "outputs": [],
   "source": [
    "#coeqtl_supp[is.na(coeqtl_supp$co_egene),]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "id": "749e9031-ce6b-44db-9d6d-371a0977c721",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 2 × 8</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>trait</th><th scope=col>identifier</th><th scope=col>egene</th><th scope=col>parameter</th><th scope=col>value</th><th scope=col>cell_type</th><th scope=col>gene</th><th scope=col>overlapping_snps</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>1</th><td>Asthma</td><td>B_RPS26___EEF1A1__RPS26</td><td>B_RPS26</td><td>PP.H0.abf</td><td>0.3734713</td><td>B</td><td>EEF1A1__RPS26</td><td>381</td></tr>\n",
       "\t<tr><th scope=row>2</th><td>Asthma</td><td>B_RPS26___EEF1A1__RPS26</td><td>B_RPS26</td><td>PP.H1.abf</td><td>0.1466712</td><td>B</td><td>EEF1A1__RPS26</td><td>381</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 2 × 8\n",
       "\\begin{tabular}{r|llllllll}\n",
       "  & trait & identifier & egene & parameter & value & cell\\_type & gene & overlapping\\_snps\\\\\n",
       "  & <chr> & <chr> & <chr> & <chr> & <dbl> & <chr> & <chr> & <dbl>\\\\\n",
       "\\hline\n",
       "\t1 & Asthma & B\\_RPS26\\_\\_\\_EEF1A1\\_\\_RPS26 & B\\_RPS26 & PP.H0.abf & 0.3734713 & B & EEF1A1\\_\\_RPS26 & 381\\\\\n",
       "\t2 & Asthma & B\\_RPS26\\_\\_\\_EEF1A1\\_\\_RPS26 & B\\_RPS26 & PP.H1.abf & 0.1466712 & B & EEF1A1\\_\\_RPS26 & 381\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 2 × 8\n",
       "\n",
       "| <!--/--> | trait &lt;chr&gt; | identifier &lt;chr&gt; | egene &lt;chr&gt; | parameter &lt;chr&gt; | value &lt;dbl&gt; | cell_type &lt;chr&gt; | gene &lt;chr&gt; | overlapping_snps &lt;dbl&gt; |\n",
       "|---|---|---|---|---|---|---|---|---|\n",
       "| 1 | Asthma | B_RPS26___EEF1A1__RPS26 | B_RPS26 | PP.H0.abf | 0.3734713 | B | EEF1A1__RPS26 | 381 |\n",
       "| 2 | Asthma | B_RPS26___EEF1A1__RPS26 | B_RPS26 | PP.H1.abf | 0.1466712 | B | EEF1A1__RPS26 | 381 |\n",
       "\n"
      ],
      "text/plain": [
       "  trait  identifier              egene   parameter value     cell_type\n",
       "1 Asthma B_RPS26___EEF1A1__RPS26 B_RPS26 PP.H0.abf 0.3734713 B        \n",
       "2 Asthma B_RPS26___EEF1A1__RPS26 B_RPS26 PP.H1.abf 0.1466712 B        \n",
       "  gene          overlapping_snps\n",
       "1 EEF1A1__RPS26 381             \n",
       "2 EEF1A1__RPS26 381             "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "head(coeqtl_supp,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "id": "c67011d0-0a18-45d5-8486-39952c05c04b",
   "metadata": {},
   "outputs": [],
   "source": [
    "coeqtl_supp = coeqtl_supp[(coeqtl_supp$parameter %in% c('PP.H3.abf','PP.H4.abf' )) ,]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "id": "0fea5320-e597-4b9e-a4e0-acff27541522",
   "metadata": {},
   "outputs": [],
   "source": [
    "coeqtl_supp$identifier = NULL"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "id": "49fd8e2d-6c83-4406-88fe-52f5cf93e3eb",
   "metadata": {},
   "outputs": [],
   "source": [
    "coeqtl_supp$egene = str_replace(coeqtl_supp$egene, '.*_', '')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6ca781c3-4e3b-4b58-b8f8-c0b0ebbdc16e",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "id": "a8ee389d-0557-425e-81e3-602b7372c41a",
   "metadata": {},
   "outputs": [],
   "source": [
    "coeqtl_supp$co_egene = coeqtl_supp$gene\n",
    "coeqtl_supp$gene = NULL\n",
    "coeqtl_supp$co_egene = str_replace(coeqtl_supp$co_egene, coeqtl_supp$egene, '')\n",
    "coeqtl_supp$co_egene = str_replace(coeqtl_supp$co_egene, '__', '')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "id": "2e94abd9-f085-482c-9cac-0dba5e2778bc",
   "metadata": {},
   "outputs": [],
   "source": [
    "coeqtl_supp$coloc_hypothesis = coeqtl_supp$parameter\n",
    "coeqtl_supp$parameter = NULL"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "id": "ede70c26-c4a2-431a-a0a2-111d9a9e27dc",
   "metadata": {},
   "outputs": [],
   "source": [
    "coeqtl_supp$cell_type = str_replace(coeqtl_supp$cell_type, '1MB', '')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "id": "d25696dd-ab8d-4e66-9f30-e2547e01203e",
   "metadata": {},
   "outputs": [],
   "source": [
    "coeqtl_supp$pp_value = coeqtl_supp$value\n",
    "coeqtl_supp$value = NULL"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "id": "49195825-a93d-42f0-8192-2662fb1210c2",
   "metadata": {},
   "outputs": [],
   "source": [
    "coeqtl_supp$amount_overlapping_snps = coeqtl_supp$overlapping_snps \n",
    "coeqtl_supp$overlapping_snps = NULL"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "id": "616b1427-8a33-47e2-9b02-5c47dc6ee1a6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 3 × 7</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>trait</th><th scope=col>egene</th><th scope=col>cell_type</th><th scope=col>co_egene</th><th scope=col>coloc_hypothesis</th><th scope=col>pp_value</th><th scope=col>amount_overlapping_snps</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>4</th><td>Asthma</td><td>RPS26</td><td>B</td><td>EEF1A1</td><td>PP.H3.abf</td><td>0.04642325</td><td>381</td></tr>\n",
       "\t<tr><th scope=row>5</th><td>Asthma</td><td>RPS26</td><td>B</td><td>EEF1A1</td><td>PP.H4.abf</td><td>0.30739863</td><td>381</td></tr>\n",
       "\t<tr><th scope=row>9</th><td>Asthma</td><td>RPS26</td><td>B</td><td>RPL10 </td><td>PP.H3.abf</td><td>0.09736711</td><td>381</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 3 × 7\n",
       "\\begin{tabular}{r|lllllll}\n",
       "  & trait & egene & cell\\_type & co\\_egene & coloc\\_hypothesis & pp\\_value & amount\\_overlapping\\_snps\\\\\n",
       "  & <chr> & <chr> & <chr> & <chr> & <chr> & <dbl> & <dbl>\\\\\n",
       "\\hline\n",
       "\t4 & Asthma & RPS26 & B & EEF1A1 & PP.H3.abf & 0.04642325 & 381\\\\\n",
       "\t5 & Asthma & RPS26 & B & EEF1A1 & PP.H4.abf & 0.30739863 & 381\\\\\n",
       "\t9 & Asthma & RPS26 & B & RPL10  & PP.H3.abf & 0.09736711 & 381\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 3 × 7\n",
       "\n",
       "| <!--/--> | trait &lt;chr&gt; | egene &lt;chr&gt; | cell_type &lt;chr&gt; | co_egene &lt;chr&gt; | coloc_hypothesis &lt;chr&gt; | pp_value &lt;dbl&gt; | amount_overlapping_snps &lt;dbl&gt; |\n",
       "|---|---|---|---|---|---|---|---|\n",
       "| 4 | Asthma | RPS26 | B | EEF1A1 | PP.H3.abf | 0.04642325 | 381 |\n",
       "| 5 | Asthma | RPS26 | B | EEF1A1 | PP.H4.abf | 0.30739863 | 381 |\n",
       "| 9 | Asthma | RPS26 | B | RPL10  | PP.H3.abf | 0.09736711 | 381 |\n",
       "\n"
      ],
      "text/plain": [
       "  trait  egene cell_type co_egene coloc_hypothesis pp_value  \n",
       "4 Asthma RPS26 B         EEF1A1   PP.H3.abf        0.04642325\n",
       "5 Asthma RPS26 B         EEF1A1   PP.H4.abf        0.30739863\n",
       "9 Asthma RPS26 B         RPL10    PP.H3.abf        0.09736711\n",
       "  amount_overlapping_snps\n",
       "4 381                    \n",
       "5 381                    \n",
       "9 381                    "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "head(coeqtl_supp,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "773b7f6e-3d4c-474b-8894-b0c903d45cf1",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "id": "9dc5dd51-e271-40f0-aa52-ddca64539cd1",
   "metadata": {},
   "outputs": [],
   "source": [
    "write.table(coeqtl_supp, file = paste0(path, \"/colocalization_results/\", \"Coloc_COEQTL_supp_table.csv\"), append =FALSE, sep = \",\", row.names = FALSE, col.names =TRUE)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7bb01b2b-7374-40f2-9373-a70e15748a32",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "53c973ec-70fa-4c5a-af44-59dcc8f24931",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1d9c3785-33d1-41c5-94f7-6780f6004305",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8e8f8e2d-26e4-488a-b766-6524f22e52da",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "bc7c75df-5623-4f72-825b-c13e25887317",
   "metadata": {},
   "source": [
    "### Get certain co-eqtl examples (RA - RPS26 H4 coegenes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "id": "730e0957-f42d-4007-aa35-08d3b568cda4",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 41 co-eGenes for Rheumatoid Arthritis with strong colocalization signal"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 116,
   "id": "0c725133-2476-4726-8b6a-1628bbe02929",
   "metadata": {},
   "outputs": [],
   "source": [
    "coeqtl_summary_filtered$gene = str_replace(coeqtl_summary_filtered$gene, '_', '')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 117,
   "id": "da16bf8c-95d2-4e10-8c62-21dc3580c04d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "152"
      ],
      "text/latex": [
       "152"
      ],
      "text/markdown": [
       "152"
      ],
      "text/plain": [
       "[1] 152"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "nrow(coeqtl_summary_filtered[(coeqtl_summary_filtered$trait == 'Rheumatoid Arthritis' ) & (coeqtl_summary_filtered$value > 0.9 )& (coeqtl_summary_filtered$parameter == 'PP.H4.abf' ),])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 118,
   "id": "53fb50d0-478c-428b-b011-922383bd7353",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 6 × 8</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>trait</th><th scope=col>identifier</th><th scope=col>egene</th><th scope=col>value</th><th scope=col>cell_type</th><th scope=col>gene</th><th scope=col>overlapping_snps</th><th scope=col>parameter</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;chr&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>1</th><td>Asthma</td><td>B_RPS26___EEF1A1__RPS26</td><td>B_RPS26</td><td>0.3734713</td><td>B</td><td>EEF1A1_RPS26</td><td>381</td><td>PP.H0.abf</td></tr>\n",
       "\t<tr><th scope=row>2</th><td>Asthma</td><td>B_RPS26___RPL10__RPS26 </td><td>B_RPS26</td><td>0.6338403</td><td>B</td><td>RPL10_RPS26 </td><td>381</td><td>PP.H4.abf</td></tr>\n",
       "\t<tr><th scope=row>3</th><td>Asthma</td><td>B_RPS26___RPL11__RPS26 </td><td>B_RPS26</td><td>0.3473292</td><td>B</td><td>RPL11_RPS26 </td><td>381</td><td>PP.H4.abf</td></tr>\n",
       "\t<tr><th scope=row>4</th><td>Asthma</td><td>B_RPS26___RPL13__RPS26 </td><td>B_RPS26</td><td>0.5521870</td><td>B</td><td>RPL13_RPS26 </td><td>381</td><td>PP.H4.abf</td></tr>\n",
       "\t<tr><th scope=row>5</th><td>Asthma</td><td>B_RPS26___RPL18__RPS26 </td><td>B_RPS26</td><td>0.5154468</td><td>B</td><td>RPL18_RPS26 </td><td>381</td><td>PP.H0.abf</td></tr>\n",
       "\t<tr><th scope=row>6</th><td>Asthma</td><td>B_RPS26___RPL21__RPS26 </td><td>B_RPS26</td><td>0.5951100</td><td>B</td><td>RPL21_RPS26 </td><td>381</td><td>PP.H4.abf</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 6 × 8\n",
       "\\begin{tabular}{r|llllllll}\n",
       "  & trait & identifier & egene & value & cell\\_type & gene & overlapping\\_snps & parameter\\\\\n",
       "  & <chr> & <chr> & <chr> & <dbl> & <chr> & <chr> & <dbl> & <chr>\\\\\n",
       "\\hline\n",
       "\t1 & Asthma & B\\_RPS26\\_\\_\\_EEF1A1\\_\\_RPS26 & B\\_RPS26 & 0.3734713 & B & EEF1A1\\_RPS26 & 381 & PP.H0.abf\\\\\n",
       "\t2 & Asthma & B\\_RPS26\\_\\_\\_RPL10\\_\\_RPS26  & B\\_RPS26 & 0.6338403 & B & RPL10\\_RPS26  & 381 & PP.H4.abf\\\\\n",
       "\t3 & Asthma & B\\_RPS26\\_\\_\\_RPL11\\_\\_RPS26  & B\\_RPS26 & 0.3473292 & B & RPL11\\_RPS26  & 381 & PP.H4.abf\\\\\n",
       "\t4 & Asthma & B\\_RPS26\\_\\_\\_RPL13\\_\\_RPS26  & B\\_RPS26 & 0.5521870 & B & RPL13\\_RPS26  & 381 & PP.H4.abf\\\\\n",
       "\t5 & Asthma & B\\_RPS26\\_\\_\\_RPL18\\_\\_RPS26  & B\\_RPS26 & 0.5154468 & B & RPL18\\_RPS26  & 381 & PP.H0.abf\\\\\n",
       "\t6 & Asthma & B\\_RPS26\\_\\_\\_RPL21\\_\\_RPS26  & B\\_RPS26 & 0.5951100 & B & RPL21\\_RPS26  & 381 & PP.H4.abf\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 6 × 8\n",
       "\n",
       "| <!--/--> | trait &lt;chr&gt; | identifier &lt;chr&gt; | egene &lt;chr&gt; | value &lt;dbl&gt; | cell_type &lt;chr&gt; | gene &lt;chr&gt; | overlapping_snps &lt;dbl&gt; | parameter &lt;chr&gt; |\n",
       "|---|---|---|---|---|---|---|---|---|\n",
       "| 1 | Asthma | B_RPS26___EEF1A1__RPS26 | B_RPS26 | 0.3734713 | B | EEF1A1_RPS26 | 381 | PP.H0.abf |\n",
       "| 2 | Asthma | B_RPS26___RPL10__RPS26  | B_RPS26 | 0.6338403 | B | RPL10_RPS26  | 381 | PP.H4.abf |\n",
       "| 3 | Asthma | B_RPS26___RPL11__RPS26  | B_RPS26 | 0.3473292 | B | RPL11_RPS26  | 381 | PP.H4.abf |\n",
       "| 4 | Asthma | B_RPS26___RPL13__RPS26  | B_RPS26 | 0.5521870 | B | RPL13_RPS26  | 381 | PP.H4.abf |\n",
       "| 5 | Asthma | B_RPS26___RPL18__RPS26  | B_RPS26 | 0.5154468 | B | RPL18_RPS26  | 381 | PP.H0.abf |\n",
       "| 6 | Asthma | B_RPS26___RPL21__RPS26  | B_RPS26 | 0.5951100 | B | RPL21_RPS26  | 381 | PP.H4.abf |\n",
       "\n"
      ],
      "text/plain": [
       "  trait  identifier              egene   value     cell_type gene        \n",
       "1 Asthma B_RPS26___EEF1A1__RPS26 B_RPS26 0.3734713 B         EEF1A1_RPS26\n",
       "2 Asthma B_RPS26___RPL10__RPS26  B_RPS26 0.6338403 B         RPL10_RPS26 \n",
       "3 Asthma B_RPS26___RPL11__RPS26  B_RPS26 0.3473292 B         RPL11_RPS26 \n",
       "4 Asthma B_RPS26___RPL13__RPS26  B_RPS26 0.5521870 B         RPL13_RPS26 \n",
       "5 Asthma B_RPS26___RPL18__RPS26  B_RPS26 0.5154468 B         RPL18_RPS26 \n",
       "6 Asthma B_RPS26___RPL21__RPS26  B_RPS26 0.5951100 B         RPL21_RPS26 \n",
       "  overlapping_snps parameter\n",
       "1 381              PP.H0.abf\n",
       "2 381              PP.H4.abf\n",
       "3 381              PP.H4.abf\n",
       "4 381              PP.H4.abf\n",
       "5 381              PP.H0.abf\n",
       "6 381              PP.H4.abf"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "head(coeqtl_summary_filtered)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "id": "62fe9449-5c40-4497-9544-5b9c08615d4a",
   "metadata": {},
   "outputs": [],
   "source": [
    "coloc_examples_rheomatoid_arthritis = coeqtl_summary_filtered[(coeqtl_summary_filtered$trait == 'Rheumatoid Arthritis' ) & (coeqtl_summary_filtered$value > 0.9 )& (coeqtl_summary_filtered$parameter == 'PP.H4.abf' ),]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "id": "7cd4a65c-a3a2-4d98-8d09-c0a89072db99",
   "metadata": {},
   "outputs": [],
   "source": [
    "#coloc_examples_rheomatoid_arthritis = coeqtl_summary_filtered[(coeqtl_summary_filtered$trait == 'Rheumatoid Arthritis' ) & (coeqtl_summary_filtered$value > 0.9 )& (coeqtl_summary_filtered$parameter == 'PP.H4.abf' ) & (coeqtl_summary_filtered$egene == 'CD4T_RPS26' ),]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "id": "64ca6b9a-3593-4431-9d98-be89635b311f",
   "metadata": {},
   "outputs": [],
   "source": [
    "analyze = coloc_examples_rheomatoid_arthritis %>% group_by( gene) %>% count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 124,
   "id": "e9a5b7c1-f312-4d0f-9acc-8e237aa16f30",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 21 × 8</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>trait</th><th scope=col>identifier</th><th scope=col>egene</th><th scope=col>value</th><th scope=col>cell_type</th><th scope=col>gene</th><th scope=col>overlapping_snps</th><th scope=col>parameter</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;chr&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>194</th><td>Asthma                    </td><td>CD4T_RPS26___HLA-DPB1__RPS26    </td><td>CD4T_RPS26    </td><td>0.5988243</td><td>CD4T    </td><td>HLA-DPB1_RPS26</td><td> 381</td><td>PP.H4.abf</td></tr>\n",
       "\t<tr><th scope=row>550</th><td>Asthma                    </td><td>CD8T_RPS26___HLA-DPB1__RPS26    </td><td>CD8T_RPS26    </td><td>0.4321920</td><td>CD8T    </td><td>HLA-DPB1_RPS26</td><td> 381</td><td>PP.H0.abf</td></tr>\n",
       "\t<tr><th scope=row>860</th><td>Asthma                    </td><td>monocyte_RPS26___HLA-DPB1__RPS26</td><td>monocyte_RPS26</td><td>0.6660012</td><td>monocyte</td><td>HLA-DPB1_RPS26</td><td> 381</td><td>PP.H4.abf</td></tr>\n",
       "\t<tr><th scope=row>1258</th><td>Crohn's Disease           </td><td>CD4T_RPS26___HLA-DPB1__RPS26    </td><td>CD4T_RPS26    </td><td>0.8220487</td><td>CD4T    </td><td>HLA-DPB1_RPS26</td><td>1112</td><td>PP.H2.abf</td></tr>\n",
       "\t<tr><th scope=row>1614</th><td>Crohn's Disease           </td><td>CD8T_RPS26___HLA-DPB1__RPS26    </td><td>CD8T_RPS26    </td><td>0.5654940</td><td>CD8T    </td><td>HLA-DPB1_RPS26</td><td>1112</td><td>PP.H0.abf</td></tr>\n",
       "\t<tr><th scope=row>1924</th><td>Crohn's Disease           </td><td>monocyte_RPS26___HLA-DPB1__RPS26</td><td>monocyte_RPS26</td><td>0.9525225</td><td>monocyte</td><td>HLA-DPB1_RPS26</td><td>1112</td><td>PP.H2.abf</td></tr>\n",
       "\t<tr><th scope=row>2322</th><td>Inflammatory Bowel Disease</td><td>CD4T_RPS26___HLA-DPB1__RPS26    </td><td>CD4T_RPS26    </td><td>0.8474188</td><td>CD4T    </td><td>HLA-DPB1_RPS26</td><td>1110</td><td>PP.H2.abf</td></tr>\n",
       "\t<tr><th scope=row>2678</th><td>Inflammatory Bowel Disease</td><td>CD8T_RPS26___HLA-DPB1__RPS26    </td><td>CD8T_RPS26    </td><td>0.5830098</td><td>CD8T    </td><td>HLA-DPB1_RPS26</td><td>1110</td><td>PP.H0.abf</td></tr>\n",
       "\t<tr><th scope=row>2988</th><td>Inflammatory Bowel Disease</td><td>monocyte_RPS26___HLA-DPB1__RPS26</td><td>monocyte_RPS26</td><td>0.9819645</td><td>monocyte</td><td>HLA-DPB1_RPS26</td><td>1110</td><td>PP.H2.abf</td></tr>\n",
       "\t<tr><th scope=row>3386</th><td>Multiple Sclerosis        </td><td>CD4T_RPS26___HLA-DPB1__RPS26    </td><td>CD4T_RPS26    </td><td>0.5847966</td><td>CD4T    </td><td>HLA-DPB1_RPS26</td><td>  58</td><td>PP.H2.abf</td></tr>\n",
       "\t<tr><th scope=row>3742</th><td>Multiple Sclerosis        </td><td>CD8T_RPS26___HLA-DPB1__RPS26    </td><td>CD8T_RPS26    </td><td>0.9170029</td><td>CD8T    </td><td>HLA-DPB1_RPS26</td><td>  58</td><td>PP.H0.abf</td></tr>\n",
       "\t<tr><th scope=row>4052</th><td>Multiple Sclerosis        </td><td>monocyte_RPS26___HLA-DPB1__RPS26</td><td>monocyte_RPS26</td><td>0.9977439</td><td>monocyte</td><td>HLA-DPB1_RPS26</td><td>  58</td><td>PP.H2.abf</td></tr>\n",
       "\t<tr><th scope=row>4450</th><td>Rheumatoid Arthritis      </td><td>CD4T_RPS26___HLA-DPB1__RPS26    </td><td>CD4T_RPS26    </td><td>0.9147419</td><td>CD4T    </td><td>HLA-DPB1_RPS26</td><td> 882</td><td>PP.H4.abf</td></tr>\n",
       "\t<tr><th scope=row>4806</th><td>Rheumatoid Arthritis      </td><td>CD8T_RPS26___HLA-DPB1__RPS26    </td><td>CD8T_RPS26    </td><td>0.7436868</td><td>CD8T    </td><td>HLA-DPB1_RPS26</td><td> 882</td><td>PP.H4.abf</td></tr>\n",
       "\t<tr><th scope=row>5116</th><td>Rheumatoid Arthritis      </td><td>monocyte_RPS26___HLA-DPB1__RPS26</td><td>monocyte_RPS26</td><td>0.7753756</td><td>monocyte</td><td>HLA-DPB1_RPS26</td><td> 882</td><td>PP.H4.abf</td></tr>\n",
       "\t<tr><th scope=row>5514</th><td>Type_1_Diabetes           </td><td>CD4T_RPS26___HLA-DPB1__RPS26    </td><td>CD4T_RPS26    </td><td>0.7693859</td><td>CD4T    </td><td>HLA-DPB1_RPS26</td><td>1341</td><td>PP.H3.abf</td></tr>\n",
       "\t<tr><th scope=row>5870</th><td>Type_1_Diabetes           </td><td>CD8T_RPS26___HLA-DPB1__RPS26    </td><td>CD8T_RPS26    </td><td>0.4314387</td><td>CD8T    </td><td>HLA-DPB1_RPS26</td><td>1341</td><td>PP.H3.abf</td></tr>\n",
       "\t<tr><th scope=row>6180</th><td>Type_1_Diabetes           </td><td>monocyte_RPS26___HLA-DPB1__RPS26</td><td>monocyte_RPS26</td><td>0.9986931</td><td>monocyte</td><td>HLA-DPB1_RPS26</td><td>1341</td><td>PP.H3.abf</td></tr>\n",
       "\t<tr><th scope=row>6578</th><td>White blood cell count    </td><td>CD4T_RPS26___HLA-DPB1__RPS26    </td><td>CD4T_RPS26    </td><td>0.8243175</td><td>CD4T    </td><td>HLA-DPB1_RPS26</td><td>1078</td><td>PP.H2.abf</td></tr>\n",
       "\t<tr><th scope=row>6934</th><td>White blood cell count    </td><td>CD8T_RPS26___HLA-DPB1__RPS26    </td><td>CD8T_RPS26    </td><td>0.5682385</td><td>CD8T    </td><td>HLA-DPB1_RPS26</td><td>1078</td><td>PP.H0.abf</td></tr>\n",
       "\t<tr><th scope=row>7244</th><td>White blood cell count    </td><td>monocyte_RPS26___HLA-DPB1__RPS26</td><td>monocyte_RPS26</td><td>0.9553423</td><td>monocyte</td><td>HLA-DPB1_RPS26</td><td>1078</td><td>PP.H2.abf</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 21 × 8\n",
       "\\begin{tabular}{r|llllllll}\n",
       "  & trait & identifier & egene & value & cell\\_type & gene & overlapping\\_snps & parameter\\\\\n",
       "  & <chr> & <chr> & <chr> & <dbl> & <chr> & <chr> & <dbl> & <chr>\\\\\n",
       "\\hline\n",
       "\t194 & Asthma                     & CD4T\\_RPS26\\_\\_\\_HLA-DPB1\\_\\_RPS26     & CD4T\\_RPS26     & 0.5988243 & CD4T     & HLA-DPB1\\_RPS26 &  381 & PP.H4.abf\\\\\n",
       "\t550 & Asthma                     & CD8T\\_RPS26\\_\\_\\_HLA-DPB1\\_\\_RPS26     & CD8T\\_RPS26     & 0.4321920 & CD8T     & HLA-DPB1\\_RPS26 &  381 & PP.H0.abf\\\\\n",
       "\t860 & Asthma                     & monocyte\\_RPS26\\_\\_\\_HLA-DPB1\\_\\_RPS26 & monocyte\\_RPS26 & 0.6660012 & monocyte & HLA-DPB1\\_RPS26 &  381 & PP.H4.abf\\\\\n",
       "\t1258 & Crohn's Disease            & CD4T\\_RPS26\\_\\_\\_HLA-DPB1\\_\\_RPS26     & CD4T\\_RPS26     & 0.8220487 & CD4T     & HLA-DPB1\\_RPS26 & 1112 & PP.H2.abf\\\\\n",
       "\t1614 & Crohn's Disease            & CD8T\\_RPS26\\_\\_\\_HLA-DPB1\\_\\_RPS26     & CD8T\\_RPS26     & 0.5654940 & CD8T     & HLA-DPB1\\_RPS26 & 1112 & PP.H0.abf\\\\\n",
       "\t1924 & Crohn's Disease            & monocyte\\_RPS26\\_\\_\\_HLA-DPB1\\_\\_RPS26 & monocyte\\_RPS26 & 0.9525225 & monocyte & HLA-DPB1\\_RPS26 & 1112 & PP.H2.abf\\\\\n",
       "\t2322 & Inflammatory Bowel Disease & CD4T\\_RPS26\\_\\_\\_HLA-DPB1\\_\\_RPS26     & CD4T\\_RPS26     & 0.8474188 & CD4T     & HLA-DPB1\\_RPS26 & 1110 & PP.H2.abf\\\\\n",
       "\t2678 & Inflammatory Bowel Disease & CD8T\\_RPS26\\_\\_\\_HLA-DPB1\\_\\_RPS26     & CD8T\\_RPS26     & 0.5830098 & CD8T     & HLA-DPB1\\_RPS26 & 1110 & PP.H0.abf\\\\\n",
       "\t2988 & Inflammatory Bowel Disease & monocyte\\_RPS26\\_\\_\\_HLA-DPB1\\_\\_RPS26 & monocyte\\_RPS26 & 0.9819645 & monocyte & HLA-DPB1\\_RPS26 & 1110 & PP.H2.abf\\\\\n",
       "\t3386 & Multiple Sclerosis         & CD4T\\_RPS26\\_\\_\\_HLA-DPB1\\_\\_RPS26     & CD4T\\_RPS26     & 0.5847966 & CD4T     & HLA-DPB1\\_RPS26 &   58 & PP.H2.abf\\\\\n",
       "\t3742 & Multiple Sclerosis         & CD8T\\_RPS26\\_\\_\\_HLA-DPB1\\_\\_RPS26     & CD8T\\_RPS26     & 0.9170029 & CD8T     & HLA-DPB1\\_RPS26 &   58 & PP.H0.abf\\\\\n",
       "\t4052 & Multiple Sclerosis         & monocyte\\_RPS26\\_\\_\\_HLA-DPB1\\_\\_RPS26 & monocyte\\_RPS26 & 0.9977439 & monocyte & HLA-DPB1\\_RPS26 &   58 & PP.H2.abf\\\\\n",
       "\t4450 & Rheumatoid Arthritis       & CD4T\\_RPS26\\_\\_\\_HLA-DPB1\\_\\_RPS26     & CD4T\\_RPS26     & 0.9147419 & CD4T     & HLA-DPB1\\_RPS26 &  882 & PP.H4.abf\\\\\n",
       "\t4806 & Rheumatoid Arthritis       & CD8T\\_RPS26\\_\\_\\_HLA-DPB1\\_\\_RPS26     & CD8T\\_RPS26     & 0.7436868 & CD8T     & HLA-DPB1\\_RPS26 &  882 & PP.H4.abf\\\\\n",
       "\t5116 & Rheumatoid Arthritis       & monocyte\\_RPS26\\_\\_\\_HLA-DPB1\\_\\_RPS26 & monocyte\\_RPS26 & 0.7753756 & monocyte & HLA-DPB1\\_RPS26 &  882 & PP.H4.abf\\\\\n",
       "\t5514 & Type\\_1\\_Diabetes            & CD4T\\_RPS26\\_\\_\\_HLA-DPB1\\_\\_RPS26     & CD4T\\_RPS26     & 0.7693859 & CD4T     & HLA-DPB1\\_RPS26 & 1341 & PP.H3.abf\\\\\n",
       "\t5870 & Type\\_1\\_Diabetes            & CD8T\\_RPS26\\_\\_\\_HLA-DPB1\\_\\_RPS26     & CD8T\\_RPS26     & 0.4314387 & CD8T     & HLA-DPB1\\_RPS26 & 1341 & PP.H3.abf\\\\\n",
       "\t6180 & Type\\_1\\_Diabetes            & monocyte\\_RPS26\\_\\_\\_HLA-DPB1\\_\\_RPS26 & monocyte\\_RPS26 & 0.9986931 & monocyte & HLA-DPB1\\_RPS26 & 1341 & PP.H3.abf\\\\\n",
       "\t6578 & White blood cell count     & CD4T\\_RPS26\\_\\_\\_HLA-DPB1\\_\\_RPS26     & CD4T\\_RPS26     & 0.8243175 & CD4T     & HLA-DPB1\\_RPS26 & 1078 & PP.H2.abf\\\\\n",
       "\t6934 & White blood cell count     & CD8T\\_RPS26\\_\\_\\_HLA-DPB1\\_\\_RPS26     & CD8T\\_RPS26     & 0.5682385 & CD8T     & HLA-DPB1\\_RPS26 & 1078 & PP.H0.abf\\\\\n",
       "\t7244 & White blood cell count     & monocyte\\_RPS26\\_\\_\\_HLA-DPB1\\_\\_RPS26 & monocyte\\_RPS26 & 0.9553423 & monocyte & HLA-DPB1\\_RPS26 & 1078 & PP.H2.abf\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 21 × 8\n",
       "\n",
       "| <!--/--> | trait &lt;chr&gt; | identifier &lt;chr&gt; | egene &lt;chr&gt; | value &lt;dbl&gt; | cell_type &lt;chr&gt; | gene &lt;chr&gt; | overlapping_snps &lt;dbl&gt; | parameter &lt;chr&gt; |\n",
       "|---|---|---|---|---|---|---|---|---|\n",
       "| 194 | Asthma                     | CD4T_RPS26___HLA-DPB1__RPS26     | CD4T_RPS26     | 0.5988243 | CD4T     | HLA-DPB1_RPS26 |  381 | PP.H4.abf |\n",
       "| 550 | Asthma                     | CD8T_RPS26___HLA-DPB1__RPS26     | CD8T_RPS26     | 0.4321920 | CD8T     | HLA-DPB1_RPS26 |  381 | PP.H0.abf |\n",
       "| 860 | Asthma                     | monocyte_RPS26___HLA-DPB1__RPS26 | monocyte_RPS26 | 0.6660012 | monocyte | HLA-DPB1_RPS26 |  381 | PP.H4.abf |\n",
       "| 1258 | Crohn's Disease            | CD4T_RPS26___HLA-DPB1__RPS26     | CD4T_RPS26     | 0.8220487 | CD4T     | HLA-DPB1_RPS26 | 1112 | PP.H2.abf |\n",
       "| 1614 | Crohn's Disease            | CD8T_RPS26___HLA-DPB1__RPS26     | CD8T_RPS26     | 0.5654940 | CD8T     | HLA-DPB1_RPS26 | 1112 | PP.H0.abf |\n",
       "| 1924 | Crohn's Disease            | monocyte_RPS26___HLA-DPB1__RPS26 | monocyte_RPS26 | 0.9525225 | monocyte | HLA-DPB1_RPS26 | 1112 | PP.H2.abf |\n",
       "| 2322 | Inflammatory Bowel Disease | CD4T_RPS26___HLA-DPB1__RPS26     | CD4T_RPS26     | 0.8474188 | CD4T     | HLA-DPB1_RPS26 | 1110 | PP.H2.abf |\n",
       "| 2678 | Inflammatory Bowel Disease | CD8T_RPS26___HLA-DPB1__RPS26     | CD8T_RPS26     | 0.5830098 | CD8T     | HLA-DPB1_RPS26 | 1110 | PP.H0.abf |\n",
       "| 2988 | Inflammatory Bowel Disease | monocyte_RPS26___HLA-DPB1__RPS26 | monocyte_RPS26 | 0.9819645 | monocyte | HLA-DPB1_RPS26 | 1110 | PP.H2.abf |\n",
       "| 3386 | Multiple Sclerosis         | CD4T_RPS26___HLA-DPB1__RPS26     | CD4T_RPS26     | 0.5847966 | CD4T     | HLA-DPB1_RPS26 |   58 | PP.H2.abf |\n",
       "| 3742 | Multiple Sclerosis         | CD8T_RPS26___HLA-DPB1__RPS26     | CD8T_RPS26     | 0.9170029 | CD8T     | HLA-DPB1_RPS26 |   58 | PP.H0.abf |\n",
       "| 4052 | Multiple Sclerosis         | monocyte_RPS26___HLA-DPB1__RPS26 | monocyte_RPS26 | 0.9977439 | monocyte | HLA-DPB1_RPS26 |   58 | PP.H2.abf |\n",
       "| 4450 | Rheumatoid Arthritis       | CD4T_RPS26___HLA-DPB1__RPS26     | CD4T_RPS26     | 0.9147419 | CD4T     | HLA-DPB1_RPS26 |  882 | PP.H4.abf |\n",
       "| 4806 | Rheumatoid Arthritis       | CD8T_RPS26___HLA-DPB1__RPS26     | CD8T_RPS26     | 0.7436868 | CD8T     | HLA-DPB1_RPS26 |  882 | PP.H4.abf |\n",
       "| 5116 | Rheumatoid Arthritis       | monocyte_RPS26___HLA-DPB1__RPS26 | monocyte_RPS26 | 0.7753756 | monocyte | HLA-DPB1_RPS26 |  882 | PP.H4.abf |\n",
       "| 5514 | Type_1_Diabetes            | CD4T_RPS26___HLA-DPB1__RPS26     | CD4T_RPS26     | 0.7693859 | CD4T     | HLA-DPB1_RPS26 | 1341 | PP.H3.abf |\n",
       "| 5870 | Type_1_Diabetes            | CD8T_RPS26___HLA-DPB1__RPS26     | CD8T_RPS26     | 0.4314387 | CD8T     | HLA-DPB1_RPS26 | 1341 | PP.H3.abf |\n",
       "| 6180 | Type_1_Diabetes            | monocyte_RPS26___HLA-DPB1__RPS26 | monocyte_RPS26 | 0.9986931 | monocyte | HLA-DPB1_RPS26 | 1341 | PP.H3.abf |\n",
       "| 6578 | White blood cell count     | CD4T_RPS26___HLA-DPB1__RPS26     | CD4T_RPS26     | 0.8243175 | CD4T     | HLA-DPB1_RPS26 | 1078 | PP.H2.abf |\n",
       "| 6934 | White blood cell count     | CD8T_RPS26___HLA-DPB1__RPS26     | CD8T_RPS26     | 0.5682385 | CD8T     | HLA-DPB1_RPS26 | 1078 | PP.H0.abf |\n",
       "| 7244 | White blood cell count     | monocyte_RPS26___HLA-DPB1__RPS26 | monocyte_RPS26 | 0.9553423 | monocyte | HLA-DPB1_RPS26 | 1078 | PP.H2.abf |\n",
       "\n"
      ],
      "text/plain": [
       "     trait                      identifier                       egene         \n",
       "194  Asthma                     CD4T_RPS26___HLA-DPB1__RPS26     CD4T_RPS26    \n",
       "550  Asthma                     CD8T_RPS26___HLA-DPB1__RPS26     CD8T_RPS26    \n",
       "860  Asthma                     monocyte_RPS26___HLA-DPB1__RPS26 monocyte_RPS26\n",
       "1258 Crohn's Disease            CD4T_RPS26___HLA-DPB1__RPS26     CD4T_RPS26    \n",
       "1614 Crohn's Disease            CD8T_RPS26___HLA-DPB1__RPS26     CD8T_RPS26    \n",
       "1924 Crohn's Disease            monocyte_RPS26___HLA-DPB1__RPS26 monocyte_RPS26\n",
       "2322 Inflammatory Bowel Disease CD4T_RPS26___HLA-DPB1__RPS26     CD4T_RPS26    \n",
       "2678 Inflammatory Bowel Disease CD8T_RPS26___HLA-DPB1__RPS26     CD8T_RPS26    \n",
       "2988 Inflammatory Bowel Disease monocyte_RPS26___HLA-DPB1__RPS26 monocyte_RPS26\n",
       "3386 Multiple Sclerosis         CD4T_RPS26___HLA-DPB1__RPS26     CD4T_RPS26    \n",
       "3742 Multiple Sclerosis         CD8T_RPS26___HLA-DPB1__RPS26     CD8T_RPS26    \n",
       "4052 Multiple Sclerosis         monocyte_RPS26___HLA-DPB1__RPS26 monocyte_RPS26\n",
       "4450 Rheumatoid Arthritis       CD4T_RPS26___HLA-DPB1__RPS26     CD4T_RPS26    \n",
       "4806 Rheumatoid Arthritis       CD8T_RPS26___HLA-DPB1__RPS26     CD8T_RPS26    \n",
       "5116 Rheumatoid Arthritis       monocyte_RPS26___HLA-DPB1__RPS26 monocyte_RPS26\n",
       "5514 Type_1_Diabetes            CD4T_RPS26___HLA-DPB1__RPS26     CD4T_RPS26    \n",
       "5870 Type_1_Diabetes            CD8T_RPS26___HLA-DPB1__RPS26     CD8T_RPS26    \n",
       "6180 Type_1_Diabetes            monocyte_RPS26___HLA-DPB1__RPS26 monocyte_RPS26\n",
       "6578 White blood cell count     CD4T_RPS26___HLA-DPB1__RPS26     CD4T_RPS26    \n",
       "6934 White blood cell count     CD8T_RPS26___HLA-DPB1__RPS26     CD8T_RPS26    \n",
       "7244 White blood cell count     monocyte_RPS26___HLA-DPB1__RPS26 monocyte_RPS26\n",
       "     value     cell_type gene           overlapping_snps parameter\n",
       "194  0.5988243 CD4T      HLA-DPB1_RPS26  381             PP.H4.abf\n",
       "550  0.4321920 CD8T      HLA-DPB1_RPS26  381             PP.H0.abf\n",
       "860  0.6660012 monocyte  HLA-DPB1_RPS26  381             PP.H4.abf\n",
       "1258 0.8220487 CD4T      HLA-DPB1_RPS26 1112             PP.H2.abf\n",
       "1614 0.5654940 CD8T      HLA-DPB1_RPS26 1112             PP.H0.abf\n",
       "1924 0.9525225 monocyte  HLA-DPB1_RPS26 1112             PP.H2.abf\n",
       "2322 0.8474188 CD4T      HLA-DPB1_RPS26 1110             PP.H2.abf\n",
       "2678 0.5830098 CD8T      HLA-DPB1_RPS26 1110             PP.H0.abf\n",
       "2988 0.9819645 monocyte  HLA-DPB1_RPS26 1110             PP.H2.abf\n",
       "3386 0.5847966 CD4T      HLA-DPB1_RPS26   58             PP.H2.abf\n",
       "3742 0.9170029 CD8T      HLA-DPB1_RPS26   58             PP.H0.abf\n",
       "4052 0.9977439 monocyte  HLA-DPB1_RPS26   58             PP.H2.abf\n",
       "4450 0.9147419 CD4T      HLA-DPB1_RPS26  882             PP.H4.abf\n",
       "4806 0.7436868 CD8T      HLA-DPB1_RPS26  882             PP.H4.abf\n",
       "5116 0.7753756 monocyte  HLA-DPB1_RPS26  882             PP.H4.abf\n",
       "5514 0.7693859 CD4T      HLA-DPB1_RPS26 1341             PP.H3.abf\n",
       "5870 0.4314387 CD8T      HLA-DPB1_RPS26 1341             PP.H3.abf\n",
       "6180 0.9986931 monocyte  HLA-DPB1_RPS26 1341             PP.H3.abf\n",
       "6578 0.8243175 CD4T      HLA-DPB1_RPS26 1078             PP.H2.abf\n",
       "6934 0.5682385 CD8T      HLA-DPB1_RPS26 1078             PP.H0.abf\n",
       "7244 0.9553423 monocyte  HLA-DPB1_RPS26 1078             PP.H2.abf"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "coeqtl_summary_filtered[coeqtl_summary_filtered$gene == 'HLA-DPB1_RPS26',]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 125,
   "id": "83e33803-4c43-41b2-9afe-11c33feb3eaa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A grouped_df: 141 × 2</caption>\n",
       "<thead>\n",
       "\t<tr><th scope=col>gene</th><th scope=col>n</th></tr>\n",
       "\t<tr><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;int&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><td>AIF1_RPS26    </td><td>2</td></tr>\n",
       "\t<tr><td>C12orf75_RPS26</td><td>2</td></tr>\n",
       "\t<tr><td>COX7C_RPS26   </td><td>2</td></tr>\n",
       "\t<tr><td>NACA_RPS26    </td><td>2</td></tr>\n",
       "\t<tr><td>RPL11_RPS26   </td><td>2</td></tr>\n",
       "\t<tr><td>RPL4_RPS26    </td><td>2</td></tr>\n",
       "\t<tr><td>RPS10_RPS26   </td><td>2</td></tr>\n",
       "\t<tr><td>RPS24_RPS26   </td><td>2</td></tr>\n",
       "\t<tr><td>RPS26_TIGIT   </td><td>2</td></tr>\n",
       "\t<tr><td>RPS26_TOMM7   </td><td>2</td></tr>\n",
       "\t<tr><td>RPS26_UBB     </td><td>2</td></tr>\n",
       "\t<tr><td>ABHD14B_RPS26 </td><td>1</td></tr>\n",
       "\t<tr><td>ABLIM1_RPS26  </td><td>1</td></tr>\n",
       "\t<tr><td>ACTB_RPS26    </td><td>1</td></tr>\n",
       "\t<tr><td>ADAM19_RPS26  </td><td>1</td></tr>\n",
       "\t<tr><td>AKAP13_RPS26  </td><td>1</td></tr>\n",
       "\t<tr><td>ANXA2_RPS26   </td><td>1</td></tr>\n",
       "\t<tr><td>APOBEC3G_RPS26</td><td>1</td></tr>\n",
       "\t<tr><td>ARPC2_RPS26   </td><td>1</td></tr>\n",
       "\t<tr><td>ATP2B1_RPS26  </td><td>1</td></tr>\n",
       "\t<tr><td>ATP2B4_RPS26  </td><td>1</td></tr>\n",
       "\t<tr><td>ATP5A1_RPS26  </td><td>1</td></tr>\n",
       "\t<tr><td>B2M_RPS26     </td><td>1</td></tr>\n",
       "\t<tr><td>BHLHE40_RPS26 </td><td>1</td></tr>\n",
       "\t<tr><td>C12orf57_RPS26</td><td>1</td></tr>\n",
       "\t<tr><td>C1orf228_RPS26</td><td>1</td></tr>\n",
       "\t<tr><td>CALM1_RPS26   </td><td>1</td></tr>\n",
       "\t<tr><td>CCL4_RPS26    </td><td>1</td></tr>\n",
       "\t<tr><td>CD48_RPS26    </td><td>1</td></tr>\n",
       "\t<tr><td>CD55_RPS26    </td><td>1</td></tr>\n",
       "\t<tr><td>⋮</td><td>⋮</td></tr>\n",
       "\t<tr><td>RPS26_RPS27A  </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_RPS3    </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_RPS4X   </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_RPS5    </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_RPS9    </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_RPSA    </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_S100A11 </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_S100A6  </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_SBDS    </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_SERF2   </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_SH3YL1  </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_SLA     </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_SMDT1   </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_SRSF2   </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_SRSF7   </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_SYNE1   </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_TCF7    </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_TESPA1  </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_TKT     </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_TMA7    </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_TMSB10  </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_TNFAIP2 </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_TNFRSF1B</td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_TUBA4A  </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_TXN     </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_UBA52   </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_UQCRB   </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_YBX1    </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_YWHAB   </td><td>1</td></tr>\n",
       "\t<tr><td>RPS26_ZEB2    </td><td>1</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A grouped\\_df: 141 × 2\n",
       "\\begin{tabular}{ll}\n",
       " gene & n\\\\\n",
       " <chr> & <int>\\\\\n",
       "\\hline\n",
       "\t AIF1\\_RPS26     & 2\\\\\n",
       "\t C12orf75\\_RPS26 & 2\\\\\n",
       "\t COX7C\\_RPS26    & 2\\\\\n",
       "\t NACA\\_RPS26     & 2\\\\\n",
       "\t RPL11\\_RPS26    & 2\\\\\n",
       "\t RPL4\\_RPS26     & 2\\\\\n",
       "\t RPS10\\_RPS26    & 2\\\\\n",
       "\t RPS24\\_RPS26    & 2\\\\\n",
       "\t RPS26\\_TIGIT    & 2\\\\\n",
       "\t RPS26\\_TOMM7    & 2\\\\\n",
       "\t RPS26\\_UBB      & 2\\\\\n",
       "\t ABHD14B\\_RPS26  & 1\\\\\n",
       "\t ABLIM1\\_RPS26   & 1\\\\\n",
       "\t ACTB\\_RPS26     & 1\\\\\n",
       "\t ADAM19\\_RPS26   & 1\\\\\n",
       "\t AKAP13\\_RPS26   & 1\\\\\n",
       "\t ANXA2\\_RPS26    & 1\\\\\n",
       "\t APOBEC3G\\_RPS26 & 1\\\\\n",
       "\t ARPC2\\_RPS26    & 1\\\\\n",
       "\t ATP2B1\\_RPS26   & 1\\\\\n",
       "\t ATP2B4\\_RPS26   & 1\\\\\n",
       "\t ATP5A1\\_RPS26   & 1\\\\\n",
       "\t B2M\\_RPS26      & 1\\\\\n",
       "\t BHLHE40\\_RPS26  & 1\\\\\n",
       "\t C12orf57\\_RPS26 & 1\\\\\n",
       "\t C1orf228\\_RPS26 & 1\\\\\n",
       "\t CALM1\\_RPS26    & 1\\\\\n",
       "\t CCL4\\_RPS26     & 1\\\\\n",
       "\t CD48\\_RPS26     & 1\\\\\n",
       "\t CD55\\_RPS26     & 1\\\\\n",
       "\t ⋮ & ⋮\\\\\n",
       "\t RPS26\\_RPS27A   & 1\\\\\n",
       "\t RPS26\\_RPS3     & 1\\\\\n",
       "\t RPS26\\_RPS4X    & 1\\\\\n",
       "\t RPS26\\_RPS5     & 1\\\\\n",
       "\t RPS26\\_RPS9     & 1\\\\\n",
       "\t RPS26\\_RPSA     & 1\\\\\n",
       "\t RPS26\\_S100A11  & 1\\\\\n",
       "\t RPS26\\_S100A6   & 1\\\\\n",
       "\t RPS26\\_SBDS     & 1\\\\\n",
       "\t RPS26\\_SERF2    & 1\\\\\n",
       "\t RPS26\\_SH3YL1   & 1\\\\\n",
       "\t RPS26\\_SLA      & 1\\\\\n",
       "\t RPS26\\_SMDT1    & 1\\\\\n",
       "\t RPS26\\_SRSF2    & 1\\\\\n",
       "\t RPS26\\_SRSF7    & 1\\\\\n",
       "\t RPS26\\_SYNE1    & 1\\\\\n",
       "\t RPS26\\_TCF7     & 1\\\\\n",
       "\t RPS26\\_TESPA1   & 1\\\\\n",
       "\t RPS26\\_TKT      & 1\\\\\n",
       "\t RPS26\\_TMA7     & 1\\\\\n",
       "\t RPS26\\_TMSB10   & 1\\\\\n",
       "\t RPS26\\_TNFAIP2  & 1\\\\\n",
       "\t RPS26\\_TNFRSF1B & 1\\\\\n",
       "\t RPS26\\_TUBA4A   & 1\\\\\n",
       "\t RPS26\\_TXN      & 1\\\\\n",
       "\t RPS26\\_UBA52    & 1\\\\\n",
       "\t RPS26\\_UQCRB    & 1\\\\\n",
       "\t RPS26\\_YBX1     & 1\\\\\n",
       "\t RPS26\\_YWHAB    & 1\\\\\n",
       "\t RPS26\\_ZEB2     & 1\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A grouped_df: 141 × 2\n",
       "\n",
       "| gene &lt;chr&gt; | n &lt;int&gt; |\n",
       "|---|---|\n",
       "| AIF1_RPS26     | 2 |\n",
       "| C12orf75_RPS26 | 2 |\n",
       "| COX7C_RPS26    | 2 |\n",
       "| NACA_RPS26     | 2 |\n",
       "| RPL11_RPS26    | 2 |\n",
       "| RPL4_RPS26     | 2 |\n",
       "| RPS10_RPS26    | 2 |\n",
       "| RPS24_RPS26    | 2 |\n",
       "| RPS26_TIGIT    | 2 |\n",
       "| RPS26_TOMM7    | 2 |\n",
       "| RPS26_UBB      | 2 |\n",
       "| ABHD14B_RPS26  | 1 |\n",
       "| ABLIM1_RPS26   | 1 |\n",
       "| ACTB_RPS26     | 1 |\n",
       "| ADAM19_RPS26   | 1 |\n",
       "| AKAP13_RPS26   | 1 |\n",
       "| ANXA2_RPS26    | 1 |\n",
       "| APOBEC3G_RPS26 | 1 |\n",
       "| ARPC2_RPS26    | 1 |\n",
       "| ATP2B1_RPS26   | 1 |\n",
       "| ATP2B4_RPS26   | 1 |\n",
       "| ATP5A1_RPS26   | 1 |\n",
       "| B2M_RPS26      | 1 |\n",
       "| BHLHE40_RPS26  | 1 |\n",
       "| C12orf57_RPS26 | 1 |\n",
       "| C1orf228_RPS26 | 1 |\n",
       "| CALM1_RPS26    | 1 |\n",
       "| CCL4_RPS26     | 1 |\n",
       "| CD48_RPS26     | 1 |\n",
       "| CD55_RPS26     | 1 |\n",
       "| ⋮ | ⋮ |\n",
       "| RPS26_RPS27A   | 1 |\n",
       "| RPS26_RPS3     | 1 |\n",
       "| RPS26_RPS4X    | 1 |\n",
       "| RPS26_RPS5     | 1 |\n",
       "| RPS26_RPS9     | 1 |\n",
       "| RPS26_RPSA     | 1 |\n",
       "| RPS26_S100A11  | 1 |\n",
       "| RPS26_S100A6   | 1 |\n",
       "| RPS26_SBDS     | 1 |\n",
       "| RPS26_SERF2    | 1 |\n",
       "| RPS26_SH3YL1   | 1 |\n",
       "| RPS26_SLA      | 1 |\n",
       "| RPS26_SMDT1    | 1 |\n",
       "| RPS26_SRSF2    | 1 |\n",
       "| RPS26_SRSF7    | 1 |\n",
       "| RPS26_SYNE1    | 1 |\n",
       "| RPS26_TCF7     | 1 |\n",
       "| RPS26_TESPA1   | 1 |\n",
       "| RPS26_TKT      | 1 |\n",
       "| RPS26_TMA7     | 1 |\n",
       "| RPS26_TMSB10   | 1 |\n",
       "| RPS26_TNFAIP2  | 1 |\n",
       "| RPS26_TNFRSF1B | 1 |\n",
       "| RPS26_TUBA4A   | 1 |\n",
       "| RPS26_TXN      | 1 |\n",
       "| RPS26_UBA52    | 1 |\n",
       "| RPS26_UQCRB    | 1 |\n",
       "| RPS26_YBX1     | 1 |\n",
       "| RPS26_YWHAB    | 1 |\n",
       "| RPS26_ZEB2     | 1 |\n",
       "\n"
      ],
      "text/plain": [
       "    gene           n\n",
       "1   AIF1_RPS26     2\n",
       "2   C12orf75_RPS26 2\n",
       "3   COX7C_RPS26    2\n",
       "4   NACA_RPS26     2\n",
       "5   RPL11_RPS26    2\n",
       "6   RPL4_RPS26     2\n",
       "7   RPS10_RPS26    2\n",
       "8   RPS24_RPS26    2\n",
       "9   RPS26_TIGIT    2\n",
       "10  RPS26_TOMM7    2\n",
       "11  RPS26_UBB      2\n",
       "12  ABHD14B_RPS26  1\n",
       "13  ABLIM1_RPS26   1\n",
       "14  ACTB_RPS26     1\n",
       "15  ADAM19_RPS26   1\n",
       "16  AKAP13_RPS26   1\n",
       "17  ANXA2_RPS26    1\n",
       "18  APOBEC3G_RPS26 1\n",
       "19  ARPC2_RPS26    1\n",
       "20  ATP2B1_RPS26   1\n",
       "21  ATP2B4_RPS26   1\n",
       "22  ATP5A1_RPS26   1\n",
       "23  B2M_RPS26      1\n",
       "24  BHLHE40_RPS26  1\n",
       "25  C12orf57_RPS26 1\n",
       "26  C1orf228_RPS26 1\n",
       "27  CALM1_RPS26    1\n",
       "28  CCL4_RPS26     1\n",
       "29  CD48_RPS26     1\n",
       "30  CD55_RPS26     1\n",
       "⋮   ⋮              ⋮\n",
       "112 RPS26_RPS27A   1\n",
       "113 RPS26_RPS3     1\n",
       "114 RPS26_RPS4X    1\n",
       "115 RPS26_RPS5     1\n",
       "116 RPS26_RPS9     1\n",
       "117 RPS26_RPSA     1\n",
       "118 RPS26_S100A11  1\n",
       "119 RPS26_S100A6   1\n",
       "120 RPS26_SBDS     1\n",
       "121 RPS26_SERF2    1\n",
       "122 RPS26_SH3YL1   1\n",
       "123 RPS26_SLA      1\n",
       "124 RPS26_SMDT1    1\n",
       "125 RPS26_SRSF2    1\n",
       "126 RPS26_SRSF7    1\n",
       "127 RPS26_SYNE1    1\n",
       "128 RPS26_TCF7     1\n",
       "129 RPS26_TESPA1   1\n",
       "130 RPS26_TKT      1\n",
       "131 RPS26_TMA7     1\n",
       "132 RPS26_TMSB10   1\n",
       "133 RPS26_TNFAIP2  1\n",
       "134 RPS26_TNFRSF1B 1\n",
       "135 RPS26_TUBA4A   1\n",
       "136 RPS26_TXN      1\n",
       "137 RPS26_UBA52    1\n",
       "138 RPS26_UQCRB    1\n",
       "139 RPS26_YBX1     1\n",
       "140 RPS26_YWHAB    1\n",
       "141 RPS26_ZEB2     1"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "analyze[order(analyze$n, decreasing = TRUE),]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 126,
   "id": "c63c24c3-091a-4fde-ace2-60db188bf889",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "141"
      ],
      "text/latex": [
       "141"
      ],
      "text/markdown": [
       "141"
      ],
      "text/plain": [
       "[1] 141"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "length(unique(coloc_examples_rheomatoid_arthritis$gene))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e881916b-4910-47dd-85db-e5827ca216fc",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 127,
   "id": "c0d63942-e313-4d77-b2ec-36a1e9ae7857",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "152"
      ],
      "text/latex": [
       "152"
      ],
      "text/markdown": [
       "152"
      ],
      "text/plain": [
       "[1] 152"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "nrow(coloc_examples_rheomatoid_arthritis %>% group_by(cell_type, gene) %>% count())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0a2253b6-6e05-4d98-98da-336a9eb2fc4d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 128,
   "id": "a0327199-e95c-4ddd-9cbb-32935629a723",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 6 × 8</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>trait</th><th scope=col>identifier</th><th scope=col>egene</th><th scope=col>value</th><th scope=col>cell_type</th><th scope=col>gene</th><th scope=col>overlapping_snps</th><th scope=col>parameter</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;chr&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>5255</th><td>Rheumatoid Arthritis</td><td>NK_RPS26___RPL23__RPS26   </td><td>NK_RPS26  </td><td>0.9777943</td><td>NK  </td><td>RPL23_RPS26 </td><td>879</td><td>PP.H4.abf</td></tr>\n",
       "\t<tr><th scope=row>4839</th><td>Rheumatoid Arthritis</td><td>CD8T_RPS26___NACA__RPS26  </td><td>CD8T_RPS26</td><td>0.9713088</td><td>CD8T</td><td>NACA_RPS26  </td><td>882</td><td>PP.H4.abf</td></tr>\n",
       "\t<tr><th scope=row>4995</th><td>Rheumatoid Arthritis</td><td>CD8T_RPS26___RPS26__UBA52 </td><td>CD8T_RPS26</td><td>0.9687585</td><td>CD8T</td><td>RPS26_UBA52 </td><td>882</td><td>PP.H4.abf</td></tr>\n",
       "\t<tr><th scope=row>5249</th><td>Rheumatoid Arthritis</td><td>NK_RPS26___RPL15__RPS26   </td><td>NK_RPS26  </td><td>0.9687209</td><td>NK  </td><td>RPL15_RPS26 </td><td>879</td><td>PP.H4.abf</td></tr>\n",
       "\t<tr><th scope=row>4764</th><td>Rheumatoid Arthritis</td><td>CD8T_RPS26___DNAJB6__RPS26</td><td>CD8T_RPS26</td><td>0.9685069</td><td>CD8T</td><td>DNAJB6_RPS26</td><td>882</td><td>PP.H4.abf</td></tr>\n",
       "\t<tr><th scope=row>4428</th><td>Rheumatoid Arthritis</td><td>CD4T_RPS26___FOXP3__RPS26 </td><td>CD4T_RPS26</td><td>0.9669022</td><td>CD4T</td><td>FOXP3_RPS26 </td><td>870</td><td>PP.H4.abf</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 6 × 8\n",
       "\\begin{tabular}{r|llllllll}\n",
       "  & trait & identifier & egene & value & cell\\_type & gene & overlapping\\_snps & parameter\\\\\n",
       "  & <chr> & <chr> & <chr> & <dbl> & <chr> & <chr> & <dbl> & <chr>\\\\\n",
       "\\hline\n",
       "\t5255 & Rheumatoid Arthritis & NK\\_RPS26\\_\\_\\_RPL23\\_\\_RPS26    & NK\\_RPS26   & 0.9777943 & NK   & RPL23\\_RPS26  & 879 & PP.H4.abf\\\\\n",
       "\t4839 & Rheumatoid Arthritis & CD8T\\_RPS26\\_\\_\\_NACA\\_\\_RPS26   & CD8T\\_RPS26 & 0.9713088 & CD8T & NACA\\_RPS26   & 882 & PP.H4.abf\\\\\n",
       "\t4995 & Rheumatoid Arthritis & CD8T\\_RPS26\\_\\_\\_RPS26\\_\\_UBA52  & CD8T\\_RPS26 & 0.9687585 & CD8T & RPS26\\_UBA52  & 882 & PP.H4.abf\\\\\n",
       "\t5249 & Rheumatoid Arthritis & NK\\_RPS26\\_\\_\\_RPL15\\_\\_RPS26    & NK\\_RPS26   & 0.9687209 & NK   & RPL15\\_RPS26  & 879 & PP.H4.abf\\\\\n",
       "\t4764 & Rheumatoid Arthritis & CD8T\\_RPS26\\_\\_\\_DNAJB6\\_\\_RPS26 & CD8T\\_RPS26 & 0.9685069 & CD8T & DNAJB6\\_RPS26 & 882 & PP.H4.abf\\\\\n",
       "\t4428 & Rheumatoid Arthritis & CD4T\\_RPS26\\_\\_\\_FOXP3\\_\\_RPS26  & CD4T\\_RPS26 & 0.9669022 & CD4T & FOXP3\\_RPS26  & 870 & PP.H4.abf\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 6 × 8\n",
       "\n",
       "| <!--/--> | trait &lt;chr&gt; | identifier &lt;chr&gt; | egene &lt;chr&gt; | value &lt;dbl&gt; | cell_type &lt;chr&gt; | gene &lt;chr&gt; | overlapping_snps &lt;dbl&gt; | parameter &lt;chr&gt; |\n",
       "|---|---|---|---|---|---|---|---|---|\n",
       "| 5255 | Rheumatoid Arthritis | NK_RPS26___RPL23__RPS26    | NK_RPS26   | 0.9777943 | NK   | RPL23_RPS26  | 879 | PP.H4.abf |\n",
       "| 4839 | Rheumatoid Arthritis | CD8T_RPS26___NACA__RPS26   | CD8T_RPS26 | 0.9713088 | CD8T | NACA_RPS26   | 882 | PP.H4.abf |\n",
       "| 4995 | Rheumatoid Arthritis | CD8T_RPS26___RPS26__UBA52  | CD8T_RPS26 | 0.9687585 | CD8T | RPS26_UBA52  | 882 | PP.H4.abf |\n",
       "| 5249 | Rheumatoid Arthritis | NK_RPS26___RPL15__RPS26    | NK_RPS26   | 0.9687209 | NK   | RPL15_RPS26  | 879 | PP.H4.abf |\n",
       "| 4764 | Rheumatoid Arthritis | CD8T_RPS26___DNAJB6__RPS26 | CD8T_RPS26 | 0.9685069 | CD8T | DNAJB6_RPS26 | 882 | PP.H4.abf |\n",
       "| 4428 | Rheumatoid Arthritis | CD4T_RPS26___FOXP3__RPS26  | CD4T_RPS26 | 0.9669022 | CD4T | FOXP3_RPS26  | 870 | PP.H4.abf |\n",
       "\n"
      ],
      "text/plain": [
       "     trait                identifier                 egene      value    \n",
       "5255 Rheumatoid Arthritis NK_RPS26___RPL23__RPS26    NK_RPS26   0.9777943\n",
       "4839 Rheumatoid Arthritis CD8T_RPS26___NACA__RPS26   CD8T_RPS26 0.9713088\n",
       "4995 Rheumatoid Arthritis CD8T_RPS26___RPS26__UBA52  CD8T_RPS26 0.9687585\n",
       "5249 Rheumatoid Arthritis NK_RPS26___RPL15__RPS26    NK_RPS26   0.9687209\n",
       "4764 Rheumatoid Arthritis CD8T_RPS26___DNAJB6__RPS26 CD8T_RPS26 0.9685069\n",
       "4428 Rheumatoid Arthritis CD4T_RPS26___FOXP3__RPS26  CD4T_RPS26 0.9669022\n",
       "     cell_type gene         overlapping_snps parameter\n",
       "5255 NK        RPL23_RPS26  879              PP.H4.abf\n",
       "4839 CD8T      NACA_RPS26   882              PP.H4.abf\n",
       "4995 CD8T      RPS26_UBA52  882              PP.H4.abf\n",
       "5249 NK        RPL15_RPS26  879              PP.H4.abf\n",
       "4764 CD8T      DNAJB6_RPS26 882              PP.H4.abf\n",
       "4428 CD4T      FOXP3_RPS26  870              PP.H4.abf"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "head(coloc_examples_rheomatoid_arthritis[order(coloc_examples_rheomatoid_arthritis$value, decreasing = TRUE),],6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "id": "65a31f3a-08d3-49b7-b722-cf610b6c8639",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A grouped_df: 5 × 2</caption>\n",
       "<thead>\n",
       "\t<tr><th scope=col>egene</th><th scope=col>n</th></tr>\n",
       "\t<tr><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;int&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><td>B_RPS26       </td><td> 4</td></tr>\n",
       "\t<tr><td>CD4T_RPS26    </td><td>41</td></tr>\n",
       "\t<tr><td>CD8T_RPS26    </td><td>64</td></tr>\n",
       "\t<tr><td>monocyte_RPS26</td><td>15</td></tr>\n",
       "\t<tr><td>NK_RPS26      </td><td>28</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A grouped\\_df: 5 × 2\n",
       "\\begin{tabular}{ll}\n",
       " egene & n\\\\\n",
       " <chr> & <int>\\\\\n",
       "\\hline\n",
       "\t B\\_RPS26        &  4\\\\\n",
       "\t CD4T\\_RPS26     & 41\\\\\n",
       "\t CD8T\\_RPS26     & 64\\\\\n",
       "\t monocyte\\_RPS26 & 15\\\\\n",
       "\t NK\\_RPS26       & 28\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A grouped_df: 5 × 2\n",
       "\n",
       "| egene &lt;chr&gt; | n &lt;int&gt; |\n",
       "|---|---|\n",
       "| B_RPS26        |  4 |\n",
       "| CD4T_RPS26     | 41 |\n",
       "| CD8T_RPS26     | 64 |\n",
       "| monocyte_RPS26 | 15 |\n",
       "| NK_RPS26       | 28 |\n",
       "\n"
      ],
      "text/plain": [
       "  egene          n \n",
       "1 B_RPS26         4\n",
       "2 CD4T_RPS26     41\n",
       "3 CD8T_RPS26     64\n",
       "4 monocyte_RPS26 15\n",
       "5 NK_RPS26       28"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "coloc_examples_rheomatoid_arthritis %>% group_by(egene) %>% count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 130,
   "id": "ec24cb29-579b-4e4f-b17b-4a2035091438",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "152"
      ],
      "text/latex": [
       "152"
      ],
      "text/markdown": [
       "152"
      ],
      "text/plain": [
       "[1] 152"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "nrow(coloc_examples_rheomatoid_arthritis)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 131,
   "id": "30b932e7-cbb0-423d-b183-ce4e04d4e7bb",
   "metadata": {},
   "outputs": [],
   "source": [
    "### Mapp positions for coegenes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 132,
   "id": "5ce1bbeb-d244-44f4-870d-ab98915db9b5",
   "metadata": {},
   "outputs": [],
   "source": [
    "coloc_examples_rheomatoid_arthritis$cogene = str_replace(coloc_examples_rheomatoid_arthritis$gene, 'RPS26', '')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 133,
   "id": "c2f1cb78-40a2-47da-8987-920eef2b7774",
   "metadata": {},
   "outputs": [],
   "source": [
    "coloc_examples_rheomatoid_arthritis$cogene = str_replace(coloc_examples_rheomatoid_arthritis$cogene, '__', '')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 134,
   "id": "746db8c7-a868-474c-900c-c93c75701808",
   "metadata": {},
   "outputs": [],
   "source": [
    "coloc_examples_rheomatoid_arthritis$cogene = str_replace(coloc_examples_rheomatoid_arthritis$cogene, '_', '')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 135,
   "id": "0e0962a6-9bf5-4bfa-a04e-c723e96e39be",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>\n",
       ".list-inline {list-style: none; margin:0; padding: 0}\n",
       ".list-inline>li {display: inline-block}\n",
       ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
       "</style>\n",
       "<ol class=list-inline><li>'RPL11'</li><li>'RPL35A'</li><li>'RPL41'</li><li>'RPLP2'</li><li>'ABHD14B'</li><li>'ADAM19'</li><li>'AIF1'</li><li>'AKAP13'</li><li>'ATP2B1'</li><li>'ATP2B4'</li><li>'C12orf75'</li><li>'CD58'</li><li>'CHCHD2'</li><li>'COX7C'</li><li>'CST7'</li><li>'CYBA'</li><li>'EML4'</li><li>'ENTPD1'</li><li>'FOXP3'</li><li>'FTH1'</li><li>'GALM'</li><li>'GK'</li><li>'H3F3A'</li><li>'HLA-DPB1'</li><li>'HLA-DRA'</li><li>'IGBP1'</li><li>'ISG20'</li><li>'LINC00493'</li><li>'LSM5'</li><li>'MIAT'</li><li>'MIR4435-1HG'</li><li>'MT2A'</li><li>'PRMT2'</li><li>'RGS1'</li><li>'RNF19A'</li><li>'SBDS'</li><li>'SERF2'</li><li>'TCF7'</li><li>'TIGIT'</li><li>'TMA7'</li><li>'TMSB10'</li><li>'TNFRSF1B'</li><li>'UBB'</li><li>'YBX1'</li><li>'YWHAB'</li><li>'ABLIM1'</li><li>'ANXA2'</li><li>'APOBEC3G'</li><li>'BHLHE40'</li><li>'C12orf57'</li><li>'C1orf228'</li><li>'CALM1'</li><li>'CCL4'</li><li>'CD55'</li><li>'CD81'</li><li>'CD8B'</li><li>'CFL1'</li><li>'CMC1'</li><li>'DNAJB6'</li><li>'EEF1D'</li><li>'EEF2'</li><li>'EIF1'</li><li>'EIF3E'</li><li>'EIF3K'</li><li>'EIF4B'</li><li>'FAIM3'</li><li>'FLNA'</li><li>'FOXP1'</li><li>'FTL'</li><li>'GLTSCR2'</li><li>'ID2'</li><li>'KLRB1'</li><li>'NACA'</li><li>'NDFIP1'</li><li>'NEAT1'</li><li>'NPM1'</li><li>'PFDN5'</li><li>'PPA1'</li><li>'PPP2R5C'</li><li>'PTPN7'</li><li>'RHOH'</li><li>'RIC3'</li><li>'RPL17'</li><li>'RPL24'</li><li>'RPL39'</li><li>'RPL4'</li><li>'RPS10'</li><li>'RPS11'</li><li>'RPS24'</li><li>'RPS4X'</li><li>'S100A6'</li><li>'SH3YL1'</li><li>'SLA'</li><li>'SMDT1'</li><li>'SRSF2'</li><li>'SRSF7'</li><li>'SYNE1'</li><li>'TESPA1'</li><li>'TOMM7'</li><li>'TUBA4A'</li><li>'TXN'</li><li>'UBA52'</li><li>'UQCRB'</li><li>'ZEB2'</li><li>'ATP5A1'</li><li>'CD48'</li><li>'EIF3L'</li><li>'FAU'</li><li>'GPX1'</li><li>'IPO7'</li><li>'QARS'</li><li>'RNASE6'</li><li>'RPL7A'</li><li>'RPS9'</li><li>'S100A11'</li><li>'TKT'</li><li>'TNFAIP2'</li><li>'ACTB'</li><li>'ARPC2'</li><li>'B2M'</li><li>'EEF1B2'</li><li>'GNB2L1'</li><li>'KLRC1'</li><li>'RPL15'</li><li>'RPL18'</li><li>'RPL23'</li><li>'RPL29'</li><li>'RPL30'</li><li>'RPL34'</li><li>'RPL35'</li><li>'RPL37'</li><li>'RPL37A'</li><li>'RPL38'</li><li>'RPL6'</li><li>'RPLP0'</li><li>'RPS16'</li><li>'RPS20'</li><li>'RPS27A'</li><li>'RPS3'</li><li>'RPS5'</li><li>'RPSA'</li></ol>\n"
      ],
      "text/latex": [
       "\\begin{enumerate*}\n",
       "\\item 'RPL11'\n",
       "\\item 'RPL35A'\n",
       "\\item 'RPL41'\n",
       "\\item 'RPLP2'\n",
       "\\item 'ABHD14B'\n",
       "\\item 'ADAM19'\n",
       "\\item 'AIF1'\n",
       "\\item 'AKAP13'\n",
       "\\item 'ATP2B1'\n",
       "\\item 'ATP2B4'\n",
       "\\item 'C12orf75'\n",
       "\\item 'CD58'\n",
       "\\item 'CHCHD2'\n",
       "\\item 'COX7C'\n",
       "\\item 'CST7'\n",
       "\\item 'CYBA'\n",
       "\\item 'EML4'\n",
       "\\item 'ENTPD1'\n",
       "\\item 'FOXP3'\n",
       "\\item 'FTH1'\n",
       "\\item 'GALM'\n",
       "\\item 'GK'\n",
       "\\item 'H3F3A'\n",
       "\\item 'HLA-DPB1'\n",
       "\\item 'HLA-DRA'\n",
       "\\item 'IGBP1'\n",
       "\\item 'ISG20'\n",
       "\\item 'LINC00493'\n",
       "\\item 'LSM5'\n",
       "\\item 'MIAT'\n",
       "\\item 'MIR4435-1HG'\n",
       "\\item 'MT2A'\n",
       "\\item 'PRMT2'\n",
       "\\item 'RGS1'\n",
       "\\item 'RNF19A'\n",
       "\\item 'SBDS'\n",
       "\\item 'SERF2'\n",
       "\\item 'TCF7'\n",
       "\\item 'TIGIT'\n",
       "\\item 'TMA7'\n",
       "\\item 'TMSB10'\n",
       "\\item 'TNFRSF1B'\n",
       "\\item 'UBB'\n",
       "\\item 'YBX1'\n",
       "\\item 'YWHAB'\n",
       "\\item 'ABLIM1'\n",
       "\\item 'ANXA2'\n",
       "\\item 'APOBEC3G'\n",
       "\\item 'BHLHE40'\n",
       "\\item 'C12orf57'\n",
       "\\item 'C1orf228'\n",
       "\\item 'CALM1'\n",
       "\\item 'CCL4'\n",
       "\\item 'CD55'\n",
       "\\item 'CD81'\n",
       "\\item 'CD8B'\n",
       "\\item 'CFL1'\n",
       "\\item 'CMC1'\n",
       "\\item 'DNAJB6'\n",
       "\\item 'EEF1D'\n",
       "\\item 'EEF2'\n",
       "\\item 'EIF1'\n",
       "\\item 'EIF3E'\n",
       "\\item 'EIF3K'\n",
       "\\item 'EIF4B'\n",
       "\\item 'FAIM3'\n",
       "\\item 'FLNA'\n",
       "\\item 'FOXP1'\n",
       "\\item 'FTL'\n",
       "\\item 'GLTSCR2'\n",
       "\\item 'ID2'\n",
       "\\item 'KLRB1'\n",
       "\\item 'NACA'\n",
       "\\item 'NDFIP1'\n",
       "\\item 'NEAT1'\n",
       "\\item 'NPM1'\n",
       "\\item 'PFDN5'\n",
       "\\item 'PPA1'\n",
       "\\item 'PPP2R5C'\n",
       "\\item 'PTPN7'\n",
       "\\item 'RHOH'\n",
       "\\item 'RIC3'\n",
       "\\item 'RPL17'\n",
       "\\item 'RPL24'\n",
       "\\item 'RPL39'\n",
       "\\item 'RPL4'\n",
       "\\item 'RPS10'\n",
       "\\item 'RPS11'\n",
       "\\item 'RPS24'\n",
       "\\item 'RPS4X'\n",
       "\\item 'S100A6'\n",
       "\\item 'SH3YL1'\n",
       "\\item 'SLA'\n",
       "\\item 'SMDT1'\n",
       "\\item 'SRSF2'\n",
       "\\item 'SRSF7'\n",
       "\\item 'SYNE1'\n",
       "\\item 'TESPA1'\n",
       "\\item 'TOMM7'\n",
       "\\item 'TUBA4A'\n",
       "\\item 'TXN'\n",
       "\\item 'UBA52'\n",
       "\\item 'UQCRB'\n",
       "\\item 'ZEB2'\n",
       "\\item 'ATP5A1'\n",
       "\\item 'CD48'\n",
       "\\item 'EIF3L'\n",
       "\\item 'FAU'\n",
       "\\item 'GPX1'\n",
       "\\item 'IPO7'\n",
       "\\item 'QARS'\n",
       "\\item 'RNASE6'\n",
       "\\item 'RPL7A'\n",
       "\\item 'RPS9'\n",
       "\\item 'S100A11'\n",
       "\\item 'TKT'\n",
       "\\item 'TNFAIP2'\n",
       "\\item 'ACTB'\n",
       "\\item 'ARPC2'\n",
       "\\item 'B2M'\n",
       "\\item 'EEF1B2'\n",
       "\\item 'GNB2L1'\n",
       "\\item 'KLRC1'\n",
       "\\item 'RPL15'\n",
       "\\item 'RPL18'\n",
       "\\item 'RPL23'\n",
       "\\item 'RPL29'\n",
       "\\item 'RPL30'\n",
       "\\item 'RPL34'\n",
       "\\item 'RPL35'\n",
       "\\item 'RPL37'\n",
       "\\item 'RPL37A'\n",
       "\\item 'RPL38'\n",
       "\\item 'RPL6'\n",
       "\\item 'RPLP0'\n",
       "\\item 'RPS16'\n",
       "\\item 'RPS20'\n",
       "\\item 'RPS27A'\n",
       "\\item 'RPS3'\n",
       "\\item 'RPS5'\n",
       "\\item 'RPSA'\n",
       "\\end{enumerate*}\n"
      ],
      "text/markdown": [
       "1. 'RPL11'\n",
       "2. 'RPL35A'\n",
       "3. 'RPL41'\n",
       "4. 'RPLP2'\n",
       "5. 'ABHD14B'\n",
       "6. 'ADAM19'\n",
       "7. 'AIF1'\n",
       "8. 'AKAP13'\n",
       "9. 'ATP2B1'\n",
       "10. 'ATP2B4'\n",
       "11. 'C12orf75'\n",
       "12. 'CD58'\n",
       "13. 'CHCHD2'\n",
       "14. 'COX7C'\n",
       "15. 'CST7'\n",
       "16. 'CYBA'\n",
       "17. 'EML4'\n",
       "18. 'ENTPD1'\n",
       "19. 'FOXP3'\n",
       "20. 'FTH1'\n",
       "21. 'GALM'\n",
       "22. 'GK'\n",
       "23. 'H3F3A'\n",
       "24. 'HLA-DPB1'\n",
       "25. 'HLA-DRA'\n",
       "26. 'IGBP1'\n",
       "27. 'ISG20'\n",
       "28. 'LINC00493'\n",
       "29. 'LSM5'\n",
       "30. 'MIAT'\n",
       "31. 'MIR4435-1HG'\n",
       "32. 'MT2A'\n",
       "33. 'PRMT2'\n",
       "34. 'RGS1'\n",
       "35. 'RNF19A'\n",
       "36. 'SBDS'\n",
       "37. 'SERF2'\n",
       "38. 'TCF7'\n",
       "39. 'TIGIT'\n",
       "40. 'TMA7'\n",
       "41. 'TMSB10'\n",
       "42. 'TNFRSF1B'\n",
       "43. 'UBB'\n",
       "44. 'YBX1'\n",
       "45. 'YWHAB'\n",
       "46. 'ABLIM1'\n",
       "47. 'ANXA2'\n",
       "48. 'APOBEC3G'\n",
       "49. 'BHLHE40'\n",
       "50. 'C12orf57'\n",
       "51. 'C1orf228'\n",
       "52. 'CALM1'\n",
       "53. 'CCL4'\n",
       "54. 'CD55'\n",
       "55. 'CD81'\n",
       "56. 'CD8B'\n",
       "57. 'CFL1'\n",
       "58. 'CMC1'\n",
       "59. 'DNAJB6'\n",
       "60. 'EEF1D'\n",
       "61. 'EEF2'\n",
       "62. 'EIF1'\n",
       "63. 'EIF3E'\n",
       "64. 'EIF3K'\n",
       "65. 'EIF4B'\n",
       "66. 'FAIM3'\n",
       "67. 'FLNA'\n",
       "68. 'FOXP1'\n",
       "69. 'FTL'\n",
       "70. 'GLTSCR2'\n",
       "71. 'ID2'\n",
       "72. 'KLRB1'\n",
       "73. 'NACA'\n",
       "74. 'NDFIP1'\n",
       "75. 'NEAT1'\n",
       "76. 'NPM1'\n",
       "77. 'PFDN5'\n",
       "78. 'PPA1'\n",
       "79. 'PPP2R5C'\n",
       "80. 'PTPN7'\n",
       "81. 'RHOH'\n",
       "82. 'RIC3'\n",
       "83. 'RPL17'\n",
       "84. 'RPL24'\n",
       "85. 'RPL39'\n",
       "86. 'RPL4'\n",
       "87. 'RPS10'\n",
       "88. 'RPS11'\n",
       "89. 'RPS24'\n",
       "90. 'RPS4X'\n",
       "91. 'S100A6'\n",
       "92. 'SH3YL1'\n",
       "93. 'SLA'\n",
       "94. 'SMDT1'\n",
       "95. 'SRSF2'\n",
       "96. 'SRSF7'\n",
       "97. 'SYNE1'\n",
       "98. 'TESPA1'\n",
       "99. 'TOMM7'\n",
       "100. 'TUBA4A'\n",
       "101. 'TXN'\n",
       "102. 'UBA52'\n",
       "103. 'UQCRB'\n",
       "104. 'ZEB2'\n",
       "105. 'ATP5A1'\n",
       "106. 'CD48'\n",
       "107. 'EIF3L'\n",
       "108. 'FAU'\n",
       "109. 'GPX1'\n",
       "110. 'IPO7'\n",
       "111. 'QARS'\n",
       "112. 'RNASE6'\n",
       "113. 'RPL7A'\n",
       "114. 'RPS9'\n",
       "115. 'S100A11'\n",
       "116. 'TKT'\n",
       "117. 'TNFAIP2'\n",
       "118. 'ACTB'\n",
       "119. 'ARPC2'\n",
       "120. 'B2M'\n",
       "121. 'EEF1B2'\n",
       "122. 'GNB2L1'\n",
       "123. 'KLRC1'\n",
       "124. 'RPL15'\n",
       "125. 'RPL18'\n",
       "126. 'RPL23'\n",
       "127. 'RPL29'\n",
       "128. 'RPL30'\n",
       "129. 'RPL34'\n",
       "130. 'RPL35'\n",
       "131. 'RPL37'\n",
       "132. 'RPL37A'\n",
       "133. 'RPL38'\n",
       "134. 'RPL6'\n",
       "135. 'RPLP0'\n",
       "136. 'RPS16'\n",
       "137. 'RPS20'\n",
       "138. 'RPS27A'\n",
       "139. 'RPS3'\n",
       "140. 'RPS5'\n",
       "141. 'RPSA'\n",
       "\n",
       "\n"
      ],
      "text/plain": [
       "  [1] \"RPL11\"       \"RPL35A\"      \"RPL41\"       \"RPLP2\"       \"ABHD14B\"    \n",
       "  [6] \"ADAM19\"      \"AIF1\"        \"AKAP13\"      \"ATP2B1\"      \"ATP2B4\"     \n",
       " [11] \"C12orf75\"    \"CD58\"        \"CHCHD2\"      \"COX7C\"       \"CST7\"       \n",
       " [16] \"CYBA\"        \"EML4\"        \"ENTPD1\"      \"FOXP3\"       \"FTH1\"       \n",
       " [21] \"GALM\"        \"GK\"          \"H3F3A\"       \"HLA-DPB1\"    \"HLA-DRA\"    \n",
       " [26] \"IGBP1\"       \"ISG20\"       \"LINC00493\"   \"LSM5\"        \"MIAT\"       \n",
       " [31] \"MIR4435-1HG\" \"MT2A\"        \"PRMT2\"       \"RGS1\"        \"RNF19A\"     \n",
       " [36] \"SBDS\"        \"SERF2\"       \"TCF7\"        \"TIGIT\"       \"TMA7\"       \n",
       " [41] \"TMSB10\"      \"TNFRSF1B\"    \"UBB\"         \"YBX1\"        \"YWHAB\"      \n",
       " [46] \"ABLIM1\"      \"ANXA2\"       \"APOBEC3G\"    \"BHLHE40\"     \"C12orf57\"   \n",
       " [51] \"C1orf228\"    \"CALM1\"       \"CCL4\"        \"CD55\"        \"CD81\"       \n",
       " [56] \"CD8B\"        \"CFL1\"        \"CMC1\"        \"DNAJB6\"      \"EEF1D\"      \n",
       " [61] \"EEF2\"        \"EIF1\"        \"EIF3E\"       \"EIF3K\"       \"EIF4B\"      \n",
       " [66] \"FAIM3\"       \"FLNA\"        \"FOXP1\"       \"FTL\"         \"GLTSCR2\"    \n",
       " [71] \"ID2\"         \"KLRB1\"       \"NACA\"        \"NDFIP1\"      \"NEAT1\"      \n",
       " [76] \"NPM1\"        \"PFDN5\"       \"PPA1\"        \"PPP2R5C\"     \"PTPN7\"      \n",
       " [81] \"RHOH\"        \"RIC3\"        \"RPL17\"       \"RPL24\"       \"RPL39\"      \n",
       " [86] \"RPL4\"        \"RPS10\"       \"RPS11\"       \"RPS24\"       \"RPS4X\"      \n",
       " [91] \"S100A6\"      \"SH3YL1\"      \"SLA\"         \"SMDT1\"       \"SRSF2\"      \n",
       " [96] \"SRSF7\"       \"SYNE1\"       \"TESPA1\"      \"TOMM7\"       \"TUBA4A\"     \n",
       "[101] \"TXN\"         \"UBA52\"       \"UQCRB\"       \"ZEB2\"        \"ATP5A1\"     \n",
       "[106] \"CD48\"        \"EIF3L\"       \"FAU\"         \"GPX1\"        \"IPO7\"       \n",
       "[111] \"QARS\"        \"RNASE6\"      \"RPL7A\"       \"RPS9\"        \"S100A11\"    \n",
       "[116] \"TKT\"         \"TNFAIP2\"     \"ACTB\"        \"ARPC2\"       \"B2M\"        \n",
       "[121] \"EEF1B2\"      \"GNB2L1\"      \"KLRC1\"       \"RPL15\"       \"RPL18\"      \n",
       "[126] \"RPL23\"       \"RPL29\"       \"RPL30\"       \"RPL34\"       \"RPL35\"      \n",
       "[131] \"RPL37\"       \"RPL37A\"      \"RPL38\"       \"RPL6\"        \"RPLP0\"      \n",
       "[136] \"RPS16\"       \"RPS20\"       \"RPS27A\"      \"RPS3\"        \"RPS5\"       \n",
       "[141] \"RPSA\"       "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "unique(coloc_examples_rheomatoid_arthritis$cogene)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 136,
   "id": "2d8a881d-640d-4d98-8b42-2aa34b9c4d2d",
   "metadata": {},
   "outputs": [],
   "source": [
    "### Retrieve gene positions an map to the data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 137,
   "id": "3fbadfc4-a9cf-40b7-956a-ebc825d536f4",
   "metadata": {},
   "outputs": [],
   "source": [
    "mart = useEnsembl(biomart = \"genes\", dataset = \"hsapiens_gene_ensembl\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 138,
   "id": "3b843643-ee9d-43e1-97f6-6c8aab485c7f",
   "metadata": {},
   "outputs": [],
   "source": [
    "geneSet =  unique(coloc_examples_rheomatoid_arthritis$cogene)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 139,
   "id": "0f5db24f-2b50-4f0a-a46a-0d3ef60fc4c5",
   "metadata": {},
   "outputs": [],
   "source": [
    "resultTable = biomaRt::getBM(attributes = c(\"start_position\",\"end_position\",\"description\", 'hgnc_symbol', 'chromosome_name'),       \n",
    "                  filters    = \"hgnc_symbol\",       \n",
    "                  values     = geneSet,         \n",
    "                  mart       = mart)     "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 140,
   "id": "87c93488-8c93-4e9f-ba07-0ef60310fe2e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "170"
      ],
      "text/latex": [
       "170"
      ],
      "text/markdown": [
       "170"
      ],
      "text/plain": [
       "[1] 170"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "nrow(resultTable)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 141,
   "id": "a3029f51-434b-4993-bc58-fa412e6ae2fa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "132"
      ],
      "text/latex": [
       "132"
      ],
      "text/markdown": [
       "132"
      ],
      "text/plain": [
       "[1] 132"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "length(unique(resultTable$hgnc_symbol))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 142,
   "id": "1e7dae2b-02e8-4209-8c0c-b38baec966c5",
   "metadata": {},
   "outputs": [],
   "source": [
    "### Filter out duplicate mappings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 143,
   "id": "18effb38-a5c8-4001-a1eb-6c9d0805b6bb",
   "metadata": {},
   "outputs": [],
   "source": [
    "filter = resultTable %>% group_by(hgnc_symbol) %>% count() %>% filter(n >= 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 144,
   "id": "f49e9ca8-6519-4952-9263-4369e56540d8",
   "metadata": {},
   "outputs": [],
   "source": [
    "filter = filter$hgnc_symbol"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 145,
   "id": "90076d21-ce15-4c7e-baa6-7a1b8165331f",
   "metadata": {},
   "outputs": [],
   "source": [
    "resultTable = resultTable[!resultTable$hgnc_symbol %in% filter,]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 146,
   "id": "db8d7392-bf41-4d9c-b44f-d102e0f571b8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>\n",
       ".list-inline {list-style: none; margin:0; padding: 0}\n",
       ".list-inline>li {display: inline-block}\n",
       ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
       "</style>\n",
       "<ol class=list-inline><li>'3'</li><li>'10'</li><li>'7'</li><li>'5'</li><li>'15'</li><li>'22'</li><li>'2'</li><li>'12'</li><li>'1'</li><li>'14'</li><li>'11'</li><li>'20'</li><li>'16'</li><li>'19'</li><li>'17'</li><li>'8'</li><li>'X'</li><li>'21'</li><li>'4'</li><li>'18'</li><li>'9'</li><li>'6'</li></ol>\n"
      ],
      "text/latex": [
       "\\begin{enumerate*}\n",
       "\\item '3'\n",
       "\\item '10'\n",
       "\\item '7'\n",
       "\\item '5'\n",
       "\\item '15'\n",
       "\\item '22'\n",
       "\\item '2'\n",
       "\\item '12'\n",
       "\\item '1'\n",
       "\\item '14'\n",
       "\\item '11'\n",
       "\\item '20'\n",
       "\\item '16'\n",
       "\\item '19'\n",
       "\\item '17'\n",
       "\\item '8'\n",
       "\\item 'X'\n",
       "\\item '21'\n",
       "\\item '4'\n",
       "\\item '18'\n",
       "\\item '9'\n",
       "\\item '6'\n",
       "\\end{enumerate*}\n"
      ],
      "text/markdown": [
       "1. '3'\n",
       "2. '10'\n",
       "3. '7'\n",
       "4. '5'\n",
       "5. '15'\n",
       "6. '22'\n",
       "7. '2'\n",
       "8. '12'\n",
       "9. '1'\n",
       "10. '14'\n",
       "11. '11'\n",
       "12. '20'\n",
       "13. '16'\n",
       "14. '19'\n",
       "15. '17'\n",
       "16. '8'\n",
       "17. 'X'\n",
       "18. '21'\n",
       "19. '4'\n",
       "20. '18'\n",
       "21. '9'\n",
       "22. '6'\n",
       "\n",
       "\n"
      ],
      "text/plain": [
       " [1] \"3\"  \"10\" \"7\"  \"5\"  \"15\" \"22\" \"2\"  \"12\" \"1\"  \"14\" \"11\" \"20\" \"16\" \"19\" \"17\"\n",
       "[16] \"8\"  \"X\"  \"21\" \"4\"  \"18\" \"9\"  \"6\" "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "unique(resultTable$chromosome_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 147,
   "id": "5cd66cd4-be5b-4aee-b318-94482723a064",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 2 × 5</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>start_position</th><th scope=col>end_position</th><th scope=col>description</th><th scope=col>hgnc_symbol</th><th scope=col>chromosome_name</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>1</th><td> 51968510</td><td> 51983409</td><td>abhydrolase domain containing 14B [Source:HGNC Symbol;Acc:HGNC:28235]</td><td>ABHD14B</td><td>3 </td></tr>\n",
       "\t<tr><th scope=row>2</th><td>114431112</td><td>114768061</td><td>actin binding LIM protein 1 [Source:HGNC Symbol;Acc:HGNC:78]         </td><td>ABLIM1 </td><td>10</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 2 × 5\n",
       "\\begin{tabular}{r|lllll}\n",
       "  & start\\_position & end\\_position & description & hgnc\\_symbol & chromosome\\_name\\\\\n",
       "  & <int> & <int> & <chr> & <chr> & <chr>\\\\\n",
       "\\hline\n",
       "\t1 &  51968510 &  51983409 & abhydrolase domain containing 14B {[}Source:HGNC Symbol;Acc:HGNC:28235{]} & ABHD14B & 3 \\\\\n",
       "\t2 & 114431112 & 114768061 & actin binding LIM protein 1 {[}Source:HGNC Symbol;Acc:HGNC:78{]}          & ABLIM1  & 10\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 2 × 5\n",
       "\n",
       "| <!--/--> | start_position &lt;int&gt; | end_position &lt;int&gt; | description &lt;chr&gt; | hgnc_symbol &lt;chr&gt; | chromosome_name &lt;chr&gt; |\n",
       "|---|---|---|---|---|---|\n",
       "| 1 |  51968510 |  51983409 | abhydrolase domain containing 14B [Source:HGNC Symbol;Acc:HGNC:28235] | ABHD14B | 3  |\n",
       "| 2 | 114431112 | 114768061 | actin binding LIM protein 1 [Source:HGNC Symbol;Acc:HGNC:78]          | ABLIM1  | 10 |\n",
       "\n"
      ],
      "text/plain": [
       "  start_position end_position\n",
       "1  51968510       51983409   \n",
       "2 114431112      114768061   \n",
       "  description                                                          \n",
       "1 abhydrolase domain containing 14B [Source:HGNC Symbol;Acc:HGNC:28235]\n",
       "2 actin binding LIM protein 1 [Source:HGNC Symbol;Acc:HGNC:78]         \n",
       "  hgnc_symbol chromosome_name\n",
       "1 ABHD14B     3              \n",
       "2 ABLIM1      10             "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "head(resultTable,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 148,
   "id": "c507579c-c4a1-4b4a-9e3c-edeabfca3da3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 2 × 9</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>trait</th><th scope=col>identifier</th><th scope=col>egene</th><th scope=col>value</th><th scope=col>cell_type</th><th scope=col>gene</th><th scope=col>overlapping_snps</th><th scope=col>parameter</th><th scope=col>cogene</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>4259</th><td>Rheumatoid Arthritis</td><td>B_RPS26___RPL11__RPS26 </td><td>B_RPS26</td><td>0.9035670</td><td>B</td><td>RPL11_RPS26 </td><td>878</td><td>PP.H4.abf</td><td>RPL11 </td></tr>\n",
       "\t<tr><th scope=row>4269</th><td>Rheumatoid Arthritis</td><td>B_RPS26___RPL35A__RPS26</td><td>B_RPS26</td><td>0.9008136</td><td>B</td><td>RPL35A_RPS26</td><td>878</td><td>PP.H4.abf</td><td>RPL35A</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 2 × 9\n",
       "\\begin{tabular}{r|lllllllll}\n",
       "  & trait & identifier & egene & value & cell\\_type & gene & overlapping\\_snps & parameter & cogene\\\\\n",
       "  & <chr> & <chr> & <chr> & <dbl> & <chr> & <chr> & <dbl> & <chr> & <chr>\\\\\n",
       "\\hline\n",
       "\t4259 & Rheumatoid Arthritis & B\\_RPS26\\_\\_\\_RPL11\\_\\_RPS26  & B\\_RPS26 & 0.9035670 & B & RPL11\\_RPS26  & 878 & PP.H4.abf & RPL11 \\\\\n",
       "\t4269 & Rheumatoid Arthritis & B\\_RPS26\\_\\_\\_RPL35A\\_\\_RPS26 & B\\_RPS26 & 0.9008136 & B & RPL35A\\_RPS26 & 878 & PP.H4.abf & RPL35A\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 2 × 9\n",
       "\n",
       "| <!--/--> | trait &lt;chr&gt; | identifier &lt;chr&gt; | egene &lt;chr&gt; | value &lt;dbl&gt; | cell_type &lt;chr&gt; | gene &lt;chr&gt; | overlapping_snps &lt;dbl&gt; | parameter &lt;chr&gt; | cogene &lt;chr&gt; |\n",
       "|---|---|---|---|---|---|---|---|---|---|\n",
       "| 4259 | Rheumatoid Arthritis | B_RPS26___RPL11__RPS26  | B_RPS26 | 0.9035670 | B | RPL11_RPS26  | 878 | PP.H4.abf | RPL11  |\n",
       "| 4269 | Rheumatoid Arthritis | B_RPS26___RPL35A__RPS26 | B_RPS26 | 0.9008136 | B | RPL35A_RPS26 | 878 | PP.H4.abf | RPL35A |\n",
       "\n"
      ],
      "text/plain": [
       "     trait                identifier              egene   value     cell_type\n",
       "4259 Rheumatoid Arthritis B_RPS26___RPL11__RPS26  B_RPS26 0.9035670 B        \n",
       "4269 Rheumatoid Arthritis B_RPS26___RPL35A__RPS26 B_RPS26 0.9008136 B        \n",
       "     gene         overlapping_snps parameter cogene\n",
       "4259 RPL11_RPS26  878              PP.H4.abf RPL11 \n",
       "4269 RPL35A_RPS26 878              PP.H4.abf RPL35A"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "head(coloc_examples_rheomatoid_arthritis,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 149,
   "id": "5fbdf162-b458-4ec4-91a0-630ddebe2724",
   "metadata": {},
   "outputs": [],
   "source": [
    "coloc_examples_rheomatoid_arthritis = merge(coloc_examples_rheomatoid_arthritis, resultTable, by.x = 'cogene', by.y = 'hgnc_symbol', all.x = TRUE)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 150,
   "id": "56c5705e-36df-4c78-8f2b-cb3b74de65f7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"dataframe\">\n",
       "<caption>A data.frame: 6 × 13</caption>\n",
       "<thead>\n",
       "\t<tr><th></th><th scope=col>cogene</th><th scope=col>trait</th><th scope=col>identifier</th><th scope=col>egene</th><th scope=col>value</th><th scope=col>cell_type</th><th scope=col>gene</th><th scope=col>overlapping_snps</th><th scope=col>parameter</th><th scope=col>start_position</th><th scope=col>end_position</th><th scope=col>description</th><th scope=col>chromosome_name</th></tr>\n",
       "\t<tr><th></th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th></tr>\n",
       "</thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>5</th><td>AIF1    </td><td>Rheumatoid Arthritis</td><td>CD4T_RPS26___AIF1__RPS26      </td><td>CD4T_RPS26    </td><td>0.9269214</td><td>CD4T    </td><td>AIF1_RPS26    </td><td>882</td><td>PP.H4.abf</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td></tr>\n",
       "\t<tr><th scope=row>6</th><td>AIF1    </td><td>Rheumatoid Arthritis</td><td>CD8T_RPS26___AIF1__RPS26      </td><td>CD8T_RPS26    </td><td>0.9590870</td><td>CD8T    </td><td>AIF1_RPS26    </td><td>882</td><td>PP.H4.abf</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td></tr>\n",
       "\t<tr><th scope=row>13</th><td>ATP5A1  </td><td>Rheumatoid Arthritis</td><td>monocyte_RPS26___ATP5A1__RPS26</td><td>monocyte_RPS26</td><td>0.9595247</td><td>monocyte</td><td>ATP5A1_RPS26  </td><td>882</td><td>PP.H4.abf</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td></tr>\n",
       "\t<tr><th scope=row>14</th><td>B2M     </td><td>Rheumatoid Arthritis</td><td>NK_RPS26___B2M__RPS26         </td><td>NK_RPS26      </td><td>0.9481042</td><td>NK      </td><td>B2M_RPS26     </td><td>879</td><td>PP.H4.abf</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td></tr>\n",
       "\t<tr><th scope=row>19</th><td>C1orf228</td><td>Rheumatoid Arthritis</td><td>CD8T_RPS26___C1orf228__RPS26  </td><td>CD8T_RPS26    </td><td>0.9100051</td><td>CD8T    </td><td>C1orf228_RPS26</td><td>881</td><td>PP.H4.abf</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td></tr>\n",
       "\t<tr><th scope=row>21</th><td>CCL4    </td><td>Rheumatoid Arthritis</td><td>CD8T_RPS26___CCL4__RPS26      </td><td>CD8T_RPS26    </td><td>0.9169790</td><td>CD8T    </td><td>CCL4_RPS26    </td><td>882</td><td>PP.H4.abf</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "A data.frame: 6 × 13\n",
       "\\begin{tabular}{r|lllllllllllll}\n",
       "  & cogene & trait & identifier & egene & value & cell\\_type & gene & overlapping\\_snps & parameter & start\\_position & end\\_position & description & chromosome\\_name\\\\\n",
       "  & <chr> & <chr> & <chr> & <chr> & <dbl> & <chr> & <chr> & <dbl> & <chr> & <int> & <int> & <chr> & <chr>\\\\\n",
       "\\hline\n",
       "\t5 & AIF1     & Rheumatoid Arthritis & CD4T\\_RPS26\\_\\_\\_AIF1\\_\\_RPS26       & CD4T\\_RPS26     & 0.9269214 & CD4T     & AIF1\\_RPS26     & 882 & PP.H4.abf & NA & NA & NA & NA\\\\\n",
       "\t6 & AIF1     & Rheumatoid Arthritis & CD8T\\_RPS26\\_\\_\\_AIF1\\_\\_RPS26       & CD8T\\_RPS26     & 0.9590870 & CD8T     & AIF1\\_RPS26     & 882 & PP.H4.abf & NA & NA & NA & NA\\\\\n",
       "\t13 & ATP5A1   & Rheumatoid Arthritis & monocyte\\_RPS26\\_\\_\\_ATP5A1\\_\\_RPS26 & monocyte\\_RPS26 & 0.9595247 & monocyte & ATP5A1\\_RPS26   & 882 & PP.H4.abf & NA & NA & NA & NA\\\\\n",
       "\t14 & B2M      & Rheumatoid Arthritis & NK\\_RPS26\\_\\_\\_B2M\\_\\_RPS26          & NK\\_RPS26       & 0.9481042 & NK       & B2M\\_RPS26      & 879 & PP.H4.abf & NA & NA & NA & NA\\\\\n",
       "\t19 & C1orf228 & Rheumatoid Arthritis & CD8T\\_RPS26\\_\\_\\_C1orf228\\_\\_RPS26   & CD8T\\_RPS26     & 0.9100051 & CD8T     & C1orf228\\_RPS26 & 881 & PP.H4.abf & NA & NA & NA & NA\\\\\n",
       "\t21 & CCL4     & Rheumatoid Arthritis & CD8T\\_RPS26\\_\\_\\_CCL4\\_\\_RPS26       & CD8T\\_RPS26     & 0.9169790 & CD8T     & CCL4\\_RPS26     & 882 & PP.H4.abf & NA & NA & NA & NA\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "A data.frame: 6 × 13\n",
       "\n",
       "| <!--/--> | cogene &lt;chr&gt; | trait &lt;chr&gt; | identifier &lt;chr&gt; | egene &lt;chr&gt; | value &lt;dbl&gt; | cell_type &lt;chr&gt; | gene &lt;chr&gt; | overlapping_snps &lt;dbl&gt; | parameter &lt;chr&gt; | start_position &lt;int&gt; | end_position &lt;int&gt; | description &lt;chr&gt; | chromosome_name &lt;chr&gt; |\n",
       "|---|---|---|---|---|---|---|---|---|---|---|---|---|---|\n",
       "| 5 | AIF1     | Rheumatoid Arthritis | CD4T_RPS26___AIF1__RPS26       | CD4T_RPS26     | 0.9269214 | CD4T     | AIF1_RPS26     | 882 | PP.H4.abf | NA | NA | NA | NA |\n",
       "| 6 | AIF1     | Rheumatoid Arthritis | CD8T_RPS26___AIF1__RPS26       | CD8T_RPS26     | 0.9590870 | CD8T     | AIF1_RPS26     | 882 | PP.H4.abf | NA | NA | NA | NA |\n",
       "| 13 | ATP5A1   | Rheumatoid Arthritis | monocyte_RPS26___ATP5A1__RPS26 | monocyte_RPS26 | 0.9595247 | monocyte | ATP5A1_RPS26   | 882 | PP.H4.abf | NA | NA | NA | NA |\n",
       "| 14 | B2M      | Rheumatoid Arthritis | NK_RPS26___B2M__RPS26          | NK_RPS26       | 0.9481042 | NK       | B2M_RPS26      | 879 | PP.H4.abf | NA | NA | NA | NA |\n",
       "| 19 | C1orf228 | Rheumatoid Arthritis | CD8T_RPS26___C1orf228__RPS26   | CD8T_RPS26     | 0.9100051 | CD8T     | C1orf228_RPS26 | 881 | PP.H4.abf | NA | NA | NA | NA |\n",
       "| 21 | CCL4     | Rheumatoid Arthritis | CD8T_RPS26___CCL4__RPS26       | CD8T_RPS26     | 0.9169790 | CD8T     | CCL4_RPS26     | 882 | PP.H4.abf | NA | NA | NA | NA |\n",
       "\n"
      ],
      "text/plain": [
       "   cogene   trait                identifier                     egene         \n",
       "5  AIF1     Rheumatoid Arthritis CD4T_RPS26___AIF1__RPS26       CD4T_RPS26    \n",
       "6  AIF1     Rheumatoid Arthritis CD8T_RPS26___AIF1__RPS26       CD8T_RPS26    \n",
       "13 ATP5A1   Rheumatoid Arthritis monocyte_RPS26___ATP5A1__RPS26 monocyte_RPS26\n",
       "14 B2M      Rheumatoid Arthritis NK_RPS26___B2M__RPS26          NK_RPS26      \n",
       "19 C1orf228 Rheumatoid Arthritis CD8T_RPS26___C1orf228__RPS26   CD8T_RPS26    \n",
       "21 CCL4     Rheumatoid Arthritis CD8T_RPS26___CCL4__RPS26       CD8T_RPS26    \n",
       "   value     cell_type gene           overlapping_snps parameter start_position\n",
       "5  0.9269214 CD4T      AIF1_RPS26     882              PP.H4.abf NA            \n",
       "6  0.9590870 CD8T      AIF1_RPS26     882              PP.H4.abf NA            \n",
       "13 0.9595247 monocyte  ATP5A1_RPS26   882              PP.H4.abf NA            \n",
       "14 0.9481042 NK        B2M_RPS26      879              PP.H4.abf NA            \n",
       "19 0.9100051 CD8T      C1orf228_RPS26 881              PP.H4.abf NA            \n",
       "21 0.9169790 CD8T      CCL4_RPS26     882              PP.H4.abf NA            \n",
       "   end_position description chromosome_name\n",
       "5  NA           NA          NA             \n",
       "6  NA           NA          NA             \n",
       "13 NA           NA          NA             \n",
       "14 NA           NA          NA             \n",
       "19 NA           NA          NA             \n",
       "21 NA           NA          NA             "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "head(coloc_examples_rheomatoid_arthritis[is.na(coloc_examples_rheomatoid_arthritis$chromosome_name),])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 151,
   "id": "5ff8f920-e5f3-4a88-8658-380368b1ee69",
   "metadata": {},
   "outputs": [],
   "source": [
    "#head(coloc_examples_rheomatoid_arthritis,4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "71e571e3-a131-4ff4-b10b-ca361e795c60",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 152,
   "id": "7f584316-cf94-4cf6-8480-1fd1dc05cc53",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "152"
      ],
      "text/latex": [
       "152"
      ],
      "text/markdown": [
       "152"
      ],
      "text/plain": [
       "[1] 152"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "nrow(coloc_examples_rheomatoid_arthritis)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 153,
   "id": "095b56c8-4aee-4d32-9c52-75c0d363877e",
   "metadata": {},
   "outputs": [],
   "source": [
    "write.table(coloc_examples_rheomatoid_arthritis, file = paste0(path, \"/colocalization_results/\", \"CD4T_RPS26_Rheomatoid_Arthritis_Colocalization_CoeGenes.csv\"), append =FALSE, sep = \",\", row.names = FALSE, col.names =TRUE)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "77eeb1ed-b252-4e30-a6ed-94bb73f2fdd1",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0e18e4ba-3e2f-4809-9933-ca9fe8d0cab3",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "R",
   "language": "R",
   "name": "ir"
  },
  "language_info": {
   "codemirror_mode": "r",
   "file_extension": ".r",
   "mimetype": "text/x-r-source",
   "name": "R",
   "pygments_lexer": "r",
   "version": "4.1.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
